tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r802606 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Hidden.java
Date Sun, 09 Aug 2009 21:11:14 GMT
Author: tedst
Date: Sun Aug  9 21:11:13 2009
New Revision: 802606

URL: http://svn.apache.org/viewvc?rev=802606&view=rev
Log:
TAP5-764: Hidden should support ClientElement and support informal parameters

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Hidden.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Hidden.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Hidden.java?rev=802606&r1=802605&r2=802606&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Hidden.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Hidden.java
Sun Aug  9 21:11:13 2009
@@ -15,8 +15,10 @@
 package org.apache.tapestry5.corelib.components;
 
 import org.apache.tapestry5.*;
+import org.apache.tapestry5.dom.Element;
 import org.apache.tapestry5.annotations.Environmental;
 import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.SupportsInformalParameters;
 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.services.ComponentDefaultProvider;
 import org.apache.tapestry5.services.FormSupport;
@@ -29,7 +31,8 @@
  *
  * @since 5.1.0.2
  */
-public class Hidden
+@SupportsInformalParameters
+public class Hidden implements ClientElement
 {
     /**
      * The value to read (when rendering) or update (when the form is submitted).
@@ -44,8 +47,12 @@
     @Parameter(required = true)
     private ValueEncoder encoder;
 
+    private String clientId;
+
     private String controlName;
 
+    private Element hiddenInputElement;
+
     @Environmental(false)
     private FormSupport formSupport;
 
@@ -61,6 +68,7 @@
     @Inject
     private Request request;
 
+
     ValueEncoder defaultEncoder()
     {
         return defaultProvider.defaultValueEncoder("value", resources);
@@ -88,14 +96,18 @@
 
         controlName = formSupport.allocateControlName(resources.getId());
 
+        clientId = null;
+
         formSupport.store(this, new ProcessSubmission(controlName));
 
         String encoded = encoder.toClient(value);
 
-        writer.element("input",
+        hiddenInputElement = writer.element("input",
                        "type", "hidden",
                        "name", controlName,
                        "value", encoded);
+        resources.renderInformalParameters(writer);
+
         writer.end();
 
         return false;
@@ -111,6 +123,15 @@
         value = decoded;
     }
 
+    public String getClientId() {
+        if (clientId == null)
+        {
+            clientId = renderSupport.allocateClientId(resources);
+            hiddenInputElement.forceAttributes("id", clientId);
+        }
+        return clientId;
+    }
+
     public String getControlName()
     {
         return controlName;



Mime
View raw message