tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1221954 - in /tapestry/tapestry5/branches/5.3/tapestry-core/src: main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java
Date Wed, 21 Dec 2011 23:51:17 GMT
Author: hlship
Date: Wed Dec 21 23:51:16 2011
New Revision: 1221954

URL: http://svn.apache.org/viewvc?rev=1221954&view=rev
Log:
TAP5-1798: Grid and BeanDisplay should ignore properties that are actually static fields

Modified:
    tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
    tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java

Modified: tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java?rev=1221954&r1=1221953&r2=1221954&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
(original)
+++ tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
Wed Dec 21 23:51:16 2011
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008, 2010 The Apache Software Foundation
+// Copyright 2007, 2008, 2010, 2011 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
 package org.apache.tapestry5.internal.services;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.util.Collections;
 import java.util.List;
 
@@ -166,20 +167,33 @@ public class BeanModelSourceImpl impleme
             PropertyAdapter pa = adapter.getPropertyAdapter(propertyName);
 
             if (!pa.isRead())
+            {
                 continue;
+            }
+
+            if (isStaticFieldProperty(pa))
+            {
+                continue;
+            }
 
             if (pa.getAnnotation(NonVisual.class) != null)
+            {
                 continue;
+            }
 
             if (filterReadOnlyProperties && !pa.isUpdate())
+            {
                 continue;
+            }
 
             final String dataType = dataTypeAnalyzer.identifyDataType(pa);
 
             // If an unregistered type, then ignore the property.
 
             if (dataType == null)
+            {
                 continue;
+            }
 
             model.add(propertyName).dataType(dataType);
         }
@@ -204,4 +218,9 @@ public class BeanModelSourceImpl impleme
 
         return model;
     }
+
+    private boolean isStaticFieldProperty(PropertyAdapter adapter)
+    {
+        return adapter.isField() && Modifier.isStatic(adapter.getField().getModifiers());
+    }
 }

Modified: tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java?rev=1221954&r1=1221953&r2=1221954&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java
(original)
+++ tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java
Wed Dec 21 23:51:16 2011
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008, 2009, 2010 The Apache Software Foundation
+// Copyright 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -676,4 +676,21 @@ public class BeanModelSourceImplTest ext
 
         verify();
     }
+
+    // https://issues.apache.org/jira/browse/TAP5-1798
+    @Test
+    public void static_fields_are_ignored()
+    {
+        Messages messages = mockMessages();
+
+        stub_contains(messages, false);
+
+        replay();
+
+        BeanModel<BeanWithStaticField> model = source.createDisplayModel(BeanWithStaticField.class,
 messages);
+
+        assertListsEquals(model.getPropertyNames(), "name");
+
+        verify();
+    }
 }



Mime
View raw message