You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2007/10/23 18:55:19 UTC

svn commit: r587555 - in /myfaces/trinidad/trunk/trinidad: src/site/xdoc/devguide/ trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/ trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad...

Author: jwaldman
Date: Tue Oct 23 09:55:16 2007
New Revision: 587555

URL: http://svn.apache.org/viewvc?rev=587555&view=rev
Log:
TRINIDAD-757
partialTriggers Contract Fails if direct parent component is not a NamingContainer
https://issues.apache.org/jira/browse/TRINIDAD-757
* changed documentation, demo, and RequestContextImpl.java

Also fixed a bug when I added translatable attribute to CoreMessages.xml where it didn't have property-extension around the property-metadata tag.

Modified:
    myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml
    myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreMessages.xml
    myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml
    myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts

Modified: myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml?rev=587555&r1=587554&r2=587555&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml (original)
+++ myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml Tue Oct 23 09:55:16 2007
@@ -143,27 +143,88 @@
 though.  (See below for other component events.)</p>
 
 <subsection name="partialTriggers: more details">
-<p>
+<P>
 It's possible to have a component that is affected by multiple triggers
 (hence, the attribute name "partialTriggers", not just "partialTrigger").
 For this, just separate each ID with a space:
-</p>
+</P>
 <source>
   &lt;tr:outputText value="#{myBean.textValue}"
                     partialTriggers="myButton1 myLink2"/&gt;
 </source>
 
-<p>
-Also, if you've got JSF NamingContainers between the trigger and its target,
+<P>
+Also, if you've got JSF NamingContainers (e.g., f:subview) between the trigger and its target,
 you'll need to incorporate that into the partialTriggers definition:
 <ul>
-<li>If you need to go through a naming container, include its ID with a colon (e.g., partialTriggers="theSubform:theLink"</li>
-<li>If you need to start at the root of the page, start with a single colon (e.g., partialTriggers=":someRootComponent"</li>
-<li>If you need to go up and out of a parent naming container, start with two colons (e.g., partialTriggers="::outsideOfMyParentNamingContainer").  To go out of two naming containers, use three colons, and so forth.</li>
+<li>If you need to go down through a naming container to get to the trigger, include the naming container's ID with a colon (e.g., partialTriggers="theSubform:theLink"</li>
+<li>If you need to start at the root of the page to get the trigger component, start with a single colon (e.g., partialTriggers=":someRootComponent"</li>
+<li>If you need to go up and out of a parent naming container to get the trigger component, start with multiple colons. 
+  <ul>
+    <li>If the target component is not a NamingContainer, then the trigger is relative to the target component. To find it relative to the parent naming
+    container, start with two colons (e.g, partialTriggers="::myTrigger"). To find it relative to the grandparent naming container,
+    start with three colons (e.g., partialTriggers=":::myTrigger"), and so forth.
+    </li>
+    <li>If the target component is a NamingContainer, then the trigger is relative to the target component's parent, not the component itself.
+    </li>
+  </ul>
+</li>
 </ul>
-</p>
+</P>
+<source>
+<![CDATA[
+  <f:view>
+    <tr:document title="Relative partialTriggers Test">
+      <tr:form>
+        <f:subview id="wrapperAroundEverything">
+          <tr:panelGroupLayout layout="vertical">
+            <!-- Button 1 is the component that all of the other buttons have partialTriggers
+                 for. -->
+            <f:subview id="button1WrapperA">
+              <f:subview id="button1WrapperB">
+                <tr:commandButton
+                  partialSubmit="true"
+                  id="button1"
+                  text="button 1 (click me then view errors in server console)"/>
+              </f:subview>
+            </f:subview>
+
+            <!-- Button 2 has four colons. Two to get it to button2WrapperB, three to get it to buttons2WrapperA,
+            and four to get it to wrapperAroundEverything. It will find the trigger from there. 
+            commandButton is not a NamingContainer -->
+            <f:subview id="button2WrapperA">
+              <f:subview id="button2WrapperB">
+                <tr:commandButton
+                  partialTriggers="::::button1WrapperA:button1WrapperB:button1"
+                  partialSubmit="true"
+                  id="button2"
+                  text="button 2"/>
+              </f:subview>
+            </f:subview>
+        ....
+            <!-- table is a NamingContainer, so finding the trigger starts
+            with the parent component -- the panelGroupLayout.. If the 
+            parent is a NamingContainer (like if you take the panelGroupLayout
+            away) then there would only be three colons. -->
+            <f:subview id="table7WrapperA">
+              <f:subview id="table7WrapperB">
+                <tr:panelGroupLayout layout="vertical">
+                  <tr:table
+                    value="#{facesContext.externalContext.requestMap.cookies}"
+                    var="row"
+                    partialTriggers="::::button1WrapperA:button1WrapperB:button1"
+                    id="table7">
+                    <tr:column headerText="Column">
+                      <tr:outputText value="#{row.name}"/>
+                    </tr:column>
+                  </tr:table>
+                </tr:panelGroupLayout>
+              </f:subview>
+            </f:subview>
+            ]]>
+</source>
 
-<p>Finally, a cool thing about partialTriggers when you're
+<P>Finally, a cool thing about partialTriggers when you're
 inside a table row.  If an event in one column needs to repaint
 a component in a different column, partialTriggers works great,
 no code required:
@@ -182,7 +243,7 @@
   &lt;/tr:column&gt;
 </source>
 This works in h:dataTable, tr:table, tr:tree or tr:treeTable, the Facelets ui:repeat, etc.  However, if you need to redraw a component in a <em>different</em> row, then you'll need to write some Java code (see RequestContext.addPartialTarget(), below).
-</p>
+</P>
 </subsection>
 <subsection name="PPR and 'rendered'">
 <p>

Modified: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreMessages.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreMessages.xml?rev=587555&r1=587554&r2=587555&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreMessages.xml (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreMessages.xml Tue Oct 23 09:55:16 2007
@@ -49,10 +49,11 @@
       <description><![CDATA[the overridden title text.]]></description>
       <property-name>text</property-name>
       <property-class>java.lang.String</property-class>
-      <mfp:property-metadata>
-         <mfp:translatable>true</mfp:translatable>
-      </mfp:property-metadata>
-      <property-extension/>
+      <property-extension>
+        <mfp:property-metadata>
+           <mfp:translatable>true</mfp:translatable>
+        </mfp:property-metadata>
+      </property-extension>
     </property>
     <property>
       <description><![CDATA[whether to render all messages or just global messages. Normally

Modified: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml?rev=587555&r1=587554&r2=587555&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml Tue Oct 23 09:55:16 2007
@@ -58,16 +58,20 @@
       </property-extension>
     </property>
     <property>
-      <description><![CDATA[the IDs of the components that should trigger a partial update.
+      <description><![CDATA[<p>the IDs of the components that should trigger a partial update.
         This component will listen on the trigger components. If one of the
         trigger components receives an event that will cause it to update
-        in some way, this component will request to be updated too.
-        Identifiers are relative to the source component, and must account for
-        NamingContainers.  If your component is already inside of a naming
-        container, you can use a single colon to start the search from the root,
-        or multiple colons to move up through the NamingContainers - "::" will
+        in some way, this component will request to be updated too.</p>
+        <p>
+        Separate multiple triggers with a space.
+        Trigger identifiers are relative to the source component for non-NamingContainer components and relative to the parent component for NamingContainer components. 
+        Identifiers must account for NamingContainers.  You can use a single colon to start the search from the root,
+        or use multiple colons to move up through the NamingContainer. For example,
+        for a non-NamingContainer component, "::" will
         search from the parent naming container, ":::" will search
-        from the grandparent naming container, etc. ]]>
+        from the grandparent naming container, etc. For a NamingContainer component,
+        "::" will search from the parent component's parent naming container. ":::" will
+        search from the parent component's grandparent naming container.</p>]]>
       </description>
       <property-name>partialTriggers</property-name>
       <property-class>java.lang.String[]</property-class>

Modified: myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx?rev=587555&r1=587554&r2=587555&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-examples/trinidad-demo/src/main/webapp/demos/pprDemos.jspx Tue Oct 23 09:55:16 2007
@@ -242,24 +242,30 @@
                            text="Go to feature demos page."/>
          </tr:panelGroupLayout>
        </tr:panelHeader>
-       <tr:panelHeader text="Naming container tests"> 
+       <tr:panelHeader text="Naming container tests; partial triggers are the previous command components with partialSubmit"> 
          <tr:panelGroupLayout layout="vertical">
            <f:subview id="sub">
-             <tr:outputFormatted  partialTriggers="::pSub_link ::pSub_button"
+             <!-- use '::' in front of the identifier to get to the parent naming
+             container, add ':::' to get to the grandparent naming container, etc.
+             This works for non-Naming Container components. -->
+             <tr:outputFormatted  partialTriggers=":::pSub_link :::pSub_button"
                                   styleUsage="instruction"
                                   value="#{partialDemoUtil.status.linkUpdate}">
                <f:convertDateTime pattern="HH:mm:ss"/>
              </tr:outputFormatted>
            </f:subview>
+             <!-- use '::' in front of the identifier to get to the parent naming
+             container, add ':::' to get to the grandparent naming container, etc.
+             This works for non-Naming Container components. -->
            <f:subview id="sub2">
             <f:subview id="sub3">
-             <tr:outputFormatted  partialTriggers=":::pSub_link :::pSub_button"
+             <tr:outputFormatted  partialTriggers="::::pSub_link ::::pSub_button"
                                   styleUsage="instruction"
                                   value="#{partialDemoUtil.status.linkUpdate}">
                <f:convertDateTime pattern="HH:mm:ss"/>
              </tr:outputFormatted>
              </f:subview>
-           </f:subview>
+           </f:subview>          
          </tr:panelGroupLayout>
        </tr:panelHeader>
        <tr:panelHeader text="This Reset button will reset all values on the page.">
@@ -278,8 +284,8 @@
           <tr:selectItem label="Index" value="/index.jspx"/>
           <tr:selectItem label="Component Demos" value="/componentDemos.jspx"/>
          </tr:selectOneChoice>
-       </tr:panelHeader>
-      </tr:panelGroupLayout>
+       </tr:panelHeader>
+      </tr:panelGroupLayout>
      </tr:panelHeader>
      </tr:panelPage>
     </tr:form>

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=587555&r1=587554&r2=587555&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Tue Oct 23 09:55:16 2007
@@ -28,6 +28,7 @@
 import java.util.Set;
 import java.util.TimeZone;
 
+import javax.faces.component.NamingContainer;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.ExternalContext;
@@ -542,15 +543,47 @@
       // inside - we want to look outside instead (at least, that was
       // the old ADF Faces rules, and now we should stick with it for
       // backwards compatibility even within Trinidad)
-      UIComponent master = ComponentUtils.findRelativeComponent(listener.getParent(),
-                                                  trigger);
-      //listener.getParent().findComponent(trigger);
+      
+      // The rule is "if the component is a naming container, search relative 
+      // to the parent; otherwise, search relative to the component." In the
+      // non-naming container case, if it fails, then search relative to the 
+      // parent, for backwards compatibility only, since we were always 
+      // searching relative to the parent.
+      UIComponent from;
+      boolean isNamingContainer = false;
+      boolean deprecatedFind = false;
+      if (listener instanceof NamingContainer)
+      {
+        from = listener.getParent();
+        isNamingContainer = true;
+      }
+      else
+        from = listener;
+        
+      UIComponent master = ComponentUtils.findRelativeComponent(from, trigger);
+      
+      if (master == null && !isNamingContainer)
+      {
+        // for backwards compatibility, look from the parent.
+        from = listener.getParent();
+        master = ComponentUtils.findRelativeComponent(from, trigger);
+        deprecatedFind = true;
+      }
+
       if (master == null)
       {
         _LOG.warning("CANNOT_FIND_PARTIAL_TRIGGER", new Object[] {trigger, listener});
       }
       else
       {
+        // if we found this with the deprecated method of searching relative to
+        // the component's parent, then warn the user to change their syntax.
+        if (deprecatedFind)
+        {
+          _LOG.warning("DEPRECATED_PARTIAL_TRIGGER_SYNTAX", 
+            new Object[] {trigger, listener});
+        }
+      
         // Get the set of listeners on this trigger and add this component.
         Set<UIComponent> listeners = pl.get(master);
         if (listeners == null)

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts?rev=587555&r1=587554&r2=587555&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts Tue Oct 23 09:55:16 2007
@@ -1053,4 +1053,7 @@
 <!-- INVALID_TIMEZONE_IN_CONFIG -->
 <resource key="INVALID_TIMEZONE_IN_CONFIG">The trinidad-config.xml contains an invalid value for time-zone ({0}). The default timezone will be used instead.</resource>
 
+
+<!-- DEPRECATED_PARTIAL_TRIGGER_SYNTAX -->
+<resource key="DEPRECATED_PARTIAL_TRIGGER_SYNTAX">Could not find partial trigger {0} from {1} searching relative to the component. The partial trigger was found relative to the component's parent but this is deprecated. Change the partial trigger to be relative to component, not relative to parent.</resource>
 </resources>