You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2017/03/31 07:23:06 UTC
tapestry-5 git commit: TAP-2532 Add property editor for object
Repository: tapestry-5
Updated Branches:
refs/heads/master 627df8511 -> 2e19fa53f
TAP-2532 Add property editor for object
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/2e19fa53
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/2e19fa53
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/2e19fa53
Branch: refs/heads/master
Commit: 2e19fa53f7ba7e931f57b0e5405a4e6fb45b77e4
Parents: 627df85
Author: Barry Books <bf...@trsvax.com>
Authored: Fri Feb 26 16:23:58 2016 -0600
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Fri Mar 31 09:21:30 2017 +0200
----------------------------------------------------------------------
.../corelib/pages/PropertyEditBlocks.java | 19 ++++++-
.../corelib/pages/PropertyEditBlocks.tml | 4 ++
.../src/test/app1/ObjectEditorDemo.tml | 13 +++++
.../integration/app1/BeanEditorTests.java | 6 ++
.../integration/app1/data/Address.java | 43 ++++++++++++++
.../tapestry5/integration/app1/pages/Index.java | 3 +-
.../app1/pages/ObjectEditorDemo.java | 15 +++++
.../integration/app1/services/AppModule.java | 60 +++++++++++++++-----
8 files changed, 147 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2e19fa53/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
index e1627af..d86dad5 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.java
@@ -18,11 +18,19 @@ import org.apache.tapestry5.SelectModel;
import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Environmental;
-import org.apache.tapestry5.corelib.components.*;
+import org.apache.tapestry5.beaneditor.BeanModel;
+import org.apache.tapestry5.corelib.components.BeanEditForm;
+import org.apache.tapestry5.corelib.components.Checkbox;
+import org.apache.tapestry5.corelib.components.DateField;
+import org.apache.tapestry5.corelib.components.PasswordField;
+import org.apache.tapestry5.corelib.components.Select;
+import org.apache.tapestry5.corelib.components.TextArea;
+import org.apache.tapestry5.corelib.components.TextField;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.services.TypeCoercer;
import org.apache.tapestry5.services.BeanBlockContribution;
import org.apache.tapestry5.services.BeanBlockSource;
+import org.apache.tapestry5.services.BeanModelSource;
import org.apache.tapestry5.services.PropertyEditContext;
import org.apache.tapestry5.util.EnumSelectModel;
import org.apache.tapestry5.util.EnumValueEncoder;
@@ -180,4 +188,13 @@ public class PropertyEditBlocks
}
return new EnumSelectModel(propertyType, context.getContainerMessages());
}
+
+ @Inject
+ private BeanModelSource beanModelSource;
+
+ @SuppressWarnings("unchecked")
+ public BeanModel<?> getModel()
+ {
+ return beanModelSource.createEditModel(context.getPropertyType(), context.getContainerMessages());
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2e19fa53/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.tml b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.tml
index 37234da..b53bc89 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.tml
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PropertyEditBlocks.tml
@@ -40,4 +40,8 @@
<t:block id="longtext">
<textarea t:id="textarea" t:mixins="formgroup"/>
</t:block>
+
+ <t:block id="object">
+ <t:beanEditor object="context.propertyValue" model="model"/>
+ </t:block>
</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2e19fa53/tapestry-core/src/test/app1/ObjectEditorDemo.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/ObjectEditorDemo.tml b/tapestry-core/src/test/app1/ObjectEditorDemo.tml
new file mode 100644
index 0000000..ec2c3bf
--- /dev/null
+++ b/tapestry-core/src/test/app1/ObjectEditorDemo.tml
@@ -0,0 +1,13 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Object BeanEditor Demo</h1>
+
+ <p>
+ Demonstrates that BeanEditor can handle address objects.
+ </p>
+
+
+ <t:beaneditform object="this"/>
+
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2e19fa53/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
index b926736..ba8dd48 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/BeanEditorTests.java
@@ -202,6 +202,12 @@ public class BeanEditorTests extends App1TestCase
assertTextPresent("Bean class from context is: " + RegistrationData.class.getName());
}
+ @Test
+ public void object_editor_test() {
+ openLinks("Object Editor Demo");
+ assertTextPresent("Street");
+ }
+
/** TAP5-991 */
public void bean_display_enum_value_from_messages()
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2e19fa53/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/Address.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/Address.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/Address.java
new file mode 100644
index 0000000..03a189a
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/Address.java
@@ -0,0 +1,43 @@
+package org.apache.tapestry5.integration.app1.data;
+
+public class Address {
+
+ private String street;
+ private String city;
+ private String state;
+ private String zip;
+
+ public String getStreet()
+ {
+ return street;
+ }
+ public void setStreet(String street)
+ {
+ this.street = street;
+ }
+ public String getCity()
+ {
+ return city;
+ }
+ public void setCity(String city)
+ {
+ this.city = city;
+ }
+ public String getState()
+ {
+ return state;
+ }
+ public void setState(String state)
+ {
+ this.state = state;
+ }
+ public String getZip()
+ {
+ return zip;
+ }
+ public void setZip(String zip)
+ {
+ this.zip = zip;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2e19fa53/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
index d483a2a..8a238e9 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
@@ -605,8 +605,9 @@ public class Index
new Item("onactivateredirect", "OnActivateRedirect Demo", "A page that redirects to itself from"
+ " its activation method"),
- new Item("BeanEditorWithFormFragmentDemo", "Bean Editor With Form Fragment Demo", "TriggerFragment mixin used inside a BeanEditor")
+ new Item("BeanEditorWithFormFragmentDemo", "Bean Editor With Form Fragment Demo", "TriggerFragment mixin used inside a BeanEditor"),
+ new Item("ObjectEditorDemo","Object Editor Demo","Edit Bean with address objects")
);
static
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2e19fa53/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ObjectEditorDemo.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ObjectEditorDemo.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ObjectEditorDemo.java
new file mode 100644
index 0000000..eb83e02
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ObjectEditorDemo.java
@@ -0,0 +1,15 @@
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.integration.app1.data.Address;
+
+public class ObjectEditorDemo {
+
+ @Property
+ Address address;
+
+ void onSuccess() {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2e19fa53/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
index f5bc575..50d0a71 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
@@ -11,19 +11,50 @@
// limitations under the License.
package org.apache.tapestry5.integration.app1.services;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.io.IOException;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ValueEncoder;
+import org.apache.tapestry5.integration.app1.data.Address;
import org.apache.tapestry5.integration.app1.data.Entity;
+import org.apache.tapestry5.integration.app1.data.Person;
+import org.apache.tapestry5.integration.app1.data.Pet;
import org.apache.tapestry5.integration.app1.data.ToDoItem;
import org.apache.tapestry5.integration.app1.data.Track;
import org.apache.tapestry5.internal.services.GenericValueEncoderFactory;
-import org.apache.tapestry5.ioc.*;
+import org.apache.tapestry5.ioc.Configuration;
+import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.OrderedConfiguration;
+import org.apache.tapestry5.ioc.Resource;
+import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.Marker;
import org.apache.tapestry5.ioc.annotations.Value;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.ioc.services.ServiceOverride;
-import org.apache.tapestry5.services.*;
+import org.apache.tapestry5.services.BaseURLSource;
+import org.apache.tapestry5.services.BeanBlockContribution;
+import org.apache.tapestry5.services.BeanBlockSource;
+import org.apache.tapestry5.services.ComponentClassResolver;
+import org.apache.tapestry5.services.EditBlockContribution;
+import org.apache.tapestry5.services.LibraryMapping;
+import org.apache.tapestry5.services.Request;
+import org.apache.tapestry5.services.RequestFilter;
+import org.apache.tapestry5.services.RequestHandler;
+import org.apache.tapestry5.services.ResourceDigestGenerator;
+import org.apache.tapestry5.services.Response;
+import org.apache.tapestry5.services.ValueEncoderFactory;
+import org.apache.tapestry5.services.ValueLabelProvider;
import org.apache.tapestry5.services.pageload.PagePreloader;
import org.apache.tapestry5.services.pageload.PreloaderMode;
import org.apache.tapestry5.services.security.ClientWhitelist;
@@ -31,18 +62,6 @@ import org.apache.tapestry5.services.security.WhitelistAnalyzer;
import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
import org.slf4j.Logger;
-import java.io.IOException;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
/**
* I was just dying to see how fast requests are!
*/
@@ -362,5 +381,18 @@ public class AppModule
configuration.add("core/exceptionreport");
configuration.add("core/t5dashboard");
}
+
+
+ public static void contributeDefaultDataTypeAnalyzer(
+ @SuppressWarnings("rawtypes") MappedConfiguration<Class, String> configuration)
+ {
+ configuration.add(Address.class, "address");
+ }
+
+ @Contribute(BeanBlockSource.class)
+ public static void provideDefaultBeanBlocks(Configuration<BeanBlockContribution> configuration)
+ {
+ configuration.add( new EditBlockContribution("address", "PropertyEditBlocks", "object"));
+ }
}