incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r484854 - in /incubator/adffaces/trunk/trinidad: trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/ trinidad-demo/src/main/webapp/demos/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadin...
Date Sat, 09 Dec 2006 00:00:53 GMT
Author: awiner
Date: Fri Dec  8 16:00:51 2006
New Revision: 484854

URL: http://svn.apache.org/viewvc?view=rev&rev=484854
Log:
ADFFACES-325: Make partialTriggers easier to use with naming containers.  In addition to supporting
IDs that start with multiple colons as a trick to jump out of naming containers, also added
a long-missing warning if the target component can't be found

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml?view=diff&rev=484854&r1=484853&r2=484854
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/includes/CommonAttrs.xml
Fri Dec  8 16:00:51 2006
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!--
   Copyright 2006 The Apache Software Foundation.
 
@@ -14,52 +14,58 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
-              xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin"
-              xmlns:mafp="http://myfaces.apache.org/maven-trinidad-plugin">
-  <component>
-    <property>
-      <description><![CDATA[Specifies CSS styles to use for this component.]]></description>
-      <property-name>inlineStyle</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:required>false</mfp:required>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[a CSS style class to use for this component.]]></description>
-      <property-name>styleClass</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:required>false</mfp:required>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[The short description of the component. This text is
commonly used by user agents to display tooltip help text.]]>
-      </description>
-      <property-name>shortDesc</property-name>
-      <property-class>java.lang.String</property-class>
-      <property-extension>
-        <mfp:required>false</mfp:required>
-        <mfp:property-metadata>
-          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
-        </mfp:property-metadata>
-      </property-extension>
-    </property>
-    <property>
-      <description><![CDATA[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.]]>
-      </description>
-      <property-name>partialTriggers</property-name>
-      <property-class>java.lang.String[]</property-class>
-    </property>
-  </component>
+<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin"
+              xmlns:mafp="http://myfaces.apache.org/maven-trinidad-plugin">
+  <component>
+    <property>
+      <description><![CDATA[Specifies CSS styles to use for this component.]]></description>
+      <property-name>inlineStyle</property-name>
+      <property-class>java.lang.String</property-class>
+      <property-extension>
+        <mfp:required>false</mfp:required>
+        <mfp:property-metadata>
+          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
+        </mfp:property-metadata>
+      </property-extension>
+    </property>
+    <property>
+      <description><![CDATA[a CSS style class to use for this component.]]></description>
+      <property-name>styleClass</property-name>
+      <property-class>java.lang.String</property-class>
+      <property-extension>
+        <mfp:required>false</mfp:required>
+        <mfp:property-metadata>
+          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
+        </mfp:property-metadata>
+      </property-extension>
+    </property>
+    <property>
+      <description><![CDATA[The short description of the component. This text is
commonly used by user agents to display tooltip help text.]]>
+      </description>
+      <property-name>shortDesc</property-name>
+      <property-class>java.lang.String</property-class>
+      <property-extension>
+        <mfp:required>false</mfp:required>
+        <mfp:property-metadata>
+          <mfp:group>${md:getTranslatedString("CORE_GROUP")}</mfp:group>
+        </mfp:property-metadata>
+      </property-extension>
+    </property>
+    <property>
+      <description><![CDATA[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
+        search from the parent naming container, ":::" will search
+        from the grandparent naming container, etc. ]]>
+      </description>
+      <property-name>partialTriggers</property-name>
+      <property-class>java.lang.String[]</property-class>
+    </property>
+  </component>
 </faces-config>

Modified: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx?view=diff&rev=484854&r1=484853&r2=484854
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx Fri
Dec  8 16:00:51 2006
@@ -246,6 +246,26 @@
                            text="Go to feature demos page."/>
          </tr:panelGroupLayout>
        </tr:panelHeader>
+       <tr:panelHeader text="Naming container tests"> 
+         <tr:panelGroupLayout layout="vertical">
+           <f:subview id="sub">
+             <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 id="sub2">
+            <f:subview id="sub3">
+             <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>
+         </tr:panelGroupLayout>
+       </tr:panelHeader>
        <tr:panelHeader text="This Reset button will reset all values on the page.">
         <tr:commandButton id="reset"
                           text="Reset"

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?view=diff&rev=484854&r1=484853&r2=484854
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
Fri Dec  8 16:00:51 2006
@@ -25,6 +25,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.FacesContext;
@@ -492,20 +493,30 @@
     {
       String trigger = triggers[i];
 
-      // Wildcards removed for now....
-      // if ("*".equals(trigger))
-      //   master = _GLOBAL_TRIGGER;
-      // else
-      UIComponent master = listener.getParent().findComponent(trigger);
-
-      // Get the set of listeners on this trigger and add this component.
-      Set<UIComponent> listeners = pl.get(master);
-      if (listeners == null)
+      // Look for the master component.  Note that if the listener is itself 
+      // a naming container, we don't want to restrict ourselves to looking
+      // 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 = _findRelativeComponent(listener.getParent(),
+                                                  trigger);
+      //listener.getParent().findComponent(trigger);
+      if (master == null)
       {
-        listeners = new HashSet<UIComponent>();
-        pl.put(master, listeners);
+        _LOG.warning("Could not find partial trigger " + trigger +
+                     " from " + listener);
+      }
+      else
+      {
+        // Get the set of listeners on this trigger and add this component.
+        Set<UIComponent> listeners = pl.get(master);
+        if (listeners == null)
+        {
+          listeners = new HashSet<UIComponent>();
+          pl.put(master, listeners);
+        }
+        listeners.add(listener);
       }
-      listeners.add(listener);
     }
   }
 
@@ -717,7 +728,42 @@
     return _partialListeners;
   }
 
+  static private UIComponent _findRelativeComponent(
+    UIComponent from,
+    String      relativeId)
+  {
+    int idLength = relativeId.length();
+    // Figure out how many colons
+    int colonCount = 0;
+    while (colonCount < idLength)
+    {
+      if (relativeId.charAt(colonCount) != NamingContainer.SEPARATOR_CHAR)
+        break;
+      colonCount++;
+    }
+
+    // colonCount == 0: fully relative
+    // colonCount == 1: absolute (still normal findComponent syntax)
+    // colonCount > 1: for each extra colon after 1, go up a naming container
+    // (to the view root, if naming containers run out)
+    if (colonCount > 1)
+    {
+      relativeId = relativeId.substring(colonCount);
+      for (int j = 1; j < colonCount; j++)
+      {
+        while (from.getParent() != null)
+        {
+          from = from.getParent();
+          if (from instanceof NamingContainer)
+            break;
+        }
+      }
+    }
+
+    return from.findComponent(relativeId);
+  }
 
+  
   private RequestContextBean _bean;
   private HelpProvider        _provider;
   private Map<UIComponent, Set<UIComponent>> _partialListeners;



Mime
View raw message