You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2010/07/13 00:50:38 UTC

svn commit: r963523 - in /myfaces/trinidad/branches/2.0.0.3.1-branch: ./ trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/ trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/ trinidad-examples/tr...

Author: gcrawford
Date: Mon Jul 12 22:50:38 2010
New Revision: 963523

URL: http://svn.apache.org/viewvc?rev=963523&view=rev
Log:
TRINIDAD-1849 subform in table not working

Added:
    myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/SubformBean.java
      - copied unchanged from r963522, myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/SubformBean.java
Modified:
    myfaces/trinidad/branches/2.0.0.3.1-branch/   (props changed)
    myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSubformTemplate.java
    myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml
    myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/components/subform.jspx

Propchange: myfaces/trinidad/branches/2.0.0.3.1-branch/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul 12 22:50:38 2010
@@ -7,4 +7,4 @@
 /myfaces/trinidad/branches/jwaldman_StyleMap:754977-770778
 /myfaces/trinidad/branches/trinidad-1.2.x:923447,923460,929241
 /myfaces/trinidad/branches/trinidad-2.0.x:823098-895949
-/myfaces/trinidad/trunk:819601,819622,834147,886881,888973,893043,896231-908455,908699-921461
+/myfaces/trinidad/trunk:819601,819622,834147,886881,888973,893043,896231-908455,908699-921461,963522

Modified: myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSubformTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSubformTemplate.java?rev=963523&r1=963522&r2=963523&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSubformTemplate.java (original)
+++ myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXSubformTemplate.java Mon Jul 12 22:50:38 2010
@@ -63,10 +63,12 @@ abstract public class UIXSubformTemplate
   @Override
   public void processValidators(FacesContext context)
   {
-    if (!isSubmitted() && isDefault() && !_isSomethingSubmitted(context))
+    boolean submitted = isSubmitted();
+
+    if (!submitted && isDefault() && !_isSomethingSubmitted(context))
       setSubmitted(true);
 
-    if (isSubmitted())
+    if (submitted)
       super.processValidators(context);
   }
 
@@ -103,6 +105,42 @@ abstract public class UIXSubformTemplate
                                getRequestMap().get(_SOMETHING_SUBMITTED));
   }
 
+  /**
+   * Sets whether the subform was submitted on this request
+   *
+   * @param submitted  the new submitted value
+   */
+  final public void setSubmitted(boolean submitted)
+  {
+    String clientId = getClientId();
+    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(
+                                                     _SUBMITTED_PREFIX + clientId,
+                                                     submitted ? Boolean.TRUE : Boolean.FALSE);
+  }
+
+  /**
+   * Gets whether the subform was submitted on this request
+   *
+   * @return  the new submitted value
+   */
+  final public boolean isSubmitted()
+  {
+    String clientId = getClientId();
+    Object submitted = FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(
+                                                                     _SUBMITTED_PREFIX + clientId);
+    return ComponentUtils.resolveBoolean(submitted, false);
+  }
+
+
   static private final String _SOMETHING_SUBMITTED =
     "org.apache.myfaces.trinidad.component.UIXSubformSubmitted";
+  static private final String _SUBMITTED_PREFIX =
+    "org.apache.myfaces.trinidad.component.UIXSubform.";
+
+ /**
+  * @deprecated submitted is request scope, and therefore will not be saved on the faces bean as a property
+  */
+  @Deprecated
+  static public final PropertyKey SUBMITTED_KEY =
+    TYPE.registerKey("submitted", Boolean.class, Boolean.FALSE, PropertyKey.CAP_NOT_BOUND | PropertyKey.CAP_TRANSIENT);
 }

Modified: myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml?rev=963523&r1=963522&r2=963523&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml (original)
+++ myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Subform.xml Mon Jul 12 22:50:38 2010
@@ -30,19 +30,6 @@
     <component-type>org.apache.myfaces.trinidad.Subform</component-type>
     <component-class>org.apache.myfaces.trinidad.component.UIXSubform</component-class>
     <property>
-      <description><![CDATA[whether the subform was submitted on this request]]></description>
-      <property-name>submitted</property-name>
-      <property-class>boolean</property-class>
-      <default-value>false</default-value>
-      <property-extension>
-        <mfp:tag-attribute-excluded>true</mfp:tag-attribute-excluded>
-        <mfp:transient>yes</mfp:transient>
-        <fmd:property-metadata>
-          <fmd:value-expression>PROHIBITED</fmd:value-expression>
-        </fmd:property-metadata>
-      </property-extension>
-    </property>
-    <property>
       <description><![CDATA[whether the subform should assume it
 has been submitted.  When set to "true", "submitted" will be
 considered true if no other subform has been submitted.]]>

Modified: myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml?rev=963523&r1=963522&r2=963523&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml Mon Jul 12 22:50:38 2010
@@ -142,6 +142,16 @@
   </managed-bean>
 
   <managed-bean>
+    <managed-bean-name>subformBean</managed-bean-name>
+    <managed-bean-class>
+       org.apache.myfaces.trinidaddemo.SubformBean
+    </managed-bean-class>
+    <managed-bean-scope>
+       request
+    </managed-bean-scope>
+  </managed-bean>
+  
+  <managed-bean>
     <managed-bean-name>dateRestrictionValidator</managed-bean-name>
     <managed-bean-class>
        org.apache.myfaces.trinidaddemo.DateRestrictionValidatorBean

Modified: myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/components/subform.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/components/subform.jspx?rev=963523&r1=963522&r2=963523&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/components/subform.jspx (original)
+++ myfaces/trinidad/branches/2.0.0.3.1-branch/trinidad-examples/trinidad-demo/src/main/webapp/components/subform.jspx Mon Jul 12 22:50:38 2010
@@ -19,31 +19,62 @@
 	   
 -->
 <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
-          xmlns:f="http://java.sun.com/jsf/core"
-          xmlns:h="http://java.sun.com/jsf/html"
+          xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
           xmlns:tr="http://myfaces.apache.org/trinidad">
- <jsp:directive.page contentType="text/html;charset=utf-8"/>
- <f:view>
-  <tr:document>
-    <tr:messages/>
-    <tr:form>
-      <tr:subform>
-        <tr:inputText required="true" label="Sub 1:"/>
-        <tr:commandButton text="Submit 1"/>
-      </tr:subform>
-
-      <tr:subform>
-        <tr:inputText required="true" label="Sub 2:"/>
-        <tr:commandButton text="Submit 2"/>
-      </tr:subform>
-
-      <tr:subform default="true">
-        <tr:inputText required="true" label="Sub Default:"/>
-        <tr:commandButton text="Submit Default"/>
-      </tr:subform>
-
-      <tr:commandButton text="Submit Outside"/>
-    </tr:form>
-  </tr:document>
- </f:view>
+  <jsp:directive.page contentType="text/html;charset=utf-8"/>
+  <f:view>
+    <tr:document>
+      <tr:messages/>
+      <tr:form>
+        <tr:subform>
+          <tr:inputText required="true" label="Sub 1:"/>
+          <tr:commandButton text="Submit 1"/>
+        </tr:subform>
+        <tr:subform>
+          <tr:inputText required="true" label="Sub 2:"/>
+          <tr:commandButton text="Submit 2"/>
+        </tr:subform>
+        <tr:subform default="true">
+          <tr:inputText required="true" label="Sub Default:"/>
+          <tr:commandButton text="Submit Default"/>
+        </tr:subform>
+        <tr:commandButton text="Submit Outside"/>
+        <tr:separator/>
+        <tr:outputText value="The fields in the 2 tables below will throw an error if they contain a string where the length is greater than 2. "/>
+        
+        <tr:spacer height="10"/>
+        <tr:outputText value="Enter 'cat' in all the field of the first table, then hit one of the 'go' buttons. Note that you only see an error for the row where you hit the go button, even though all the rows contain a string where the length is greater than 2. This is because each row of the first column is in its own subform, so only the row in which the button was pressed is running the full lifecycle"/>
+        <tr:table id="i1" value="#{subformBean.texts}" var="row">
+          <tr:column>
+            <tr:subform id="s1">
+              <tr:panelGroupLayout id="pgl0" layout="horizontal">
+                <tr:inputText label="Enter text" id="it1" value="#{row.text}">
+                  <tr:validateLength maximum="2"/>
+                </tr:inputText>
+                <tr:commandButton text="Go" id="go" actionListener="#{row.doSomething}"/>
+              </tr:panelGroupLayout>
+            </tr:subform>
+          </tr:column>
+          <tr:column>
+            <tr:outputText id="ot1" value="#{row.text}" />
+          </tr:column>
+        </tr:table>
+        <tr:spacer height="10"/>
+        <tr:outputText value="Enter 'cat' in all the field of the second table, then hit one of the 'go' buttons. Note that you see an error for all the rows. There is no subform in this table, therefore regardless of which button you hit, the full table is processed."/>
+        <tr:table id="t2" value="#{subformBean.texts2}" var="row">
+          <tr:column>
+              <tr:panelGroupLayout id="pgl1" layout="horizontal">
+                <tr:inputText label="Enter text" id="it2" value="#{row.text}">
+                  <tr:validateLength maximum="2"/>
+                </tr:inputText>
+                <tr:commandButton text="Go" id="go2" actionListener="#{row.doSomething}"/>
+              </tr:panelGroupLayout>
+          </tr:column>
+          <tr:column>
+            <tr:outputText id="ot2" value="#{row.text}" />
+          </tr:column>
+        </tr:table>
+      </tr:form>
+    </tr:document>
+  </f:view>
 </jsp:root>