You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/12/22 00:50:28 UTC
svn commit: r1221952 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/internal/services/
test/java/org/apache/tapestry5/internal/services/
Author: hlship
Date: Wed Dec 21 23:50:28 2011
New Revision: 1221952
URL: http://svn.apache.org/viewvc?rev=1221952&view=rev
Log:
TAP5-1798: Grid and BeanDisplay should ignore properties that are actually static fields
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java?rev=1221952&r1=1221951&r2=1221952&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java Wed Dec 21 23:50:28 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.
@@ -31,6 +31,7 @@ import org.apache.tapestry5.services.Dat
import org.apache.tapestry5.services.PropertyConduitSource;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.List;
@@ -162,20 +163,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);
}
@@ -200,4 +214,9 @@ public class BeanModelSourceImpl impleme
return model;
}
+
+ private boolean isStaticFieldProperty(PropertyAdapter adapter)
+ {
+ return adapter.isField() && Modifier.isStatic(adapter.getField().getModifiers());
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java?rev=1221952&r1=1221951&r2=1221952&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanModelSourceImplTest.java Wed Dec 21 23:50:28 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();
+ }
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java?rev=1221952&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanWithStaticField.java Wed Dec 21 23:50:28 2011
@@ -0,0 +1,8 @@
+package org.apache.tapestry5.internal.services;
+
+public class BeanWithStaticField
+{
+ public static final String DEFAULT_NAME = "Joe";
+
+ public String name = DEFAULT_NAME;
+}