You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bs...@apache.org on 2010/12/31 00:58:05 UTC

svn commit: r1054027 - in /myfaces/trinidad/trunk: trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/ trinidad-examples/trinidad-demo/src/main/webapp/demos/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/

Author: bsullivan
Date: Thu Dec 30 23:58:05 2010
New Revision: 1054027

URL: http://svn.apache.org/viewvc?rev=1054027&view=rev
Log:
TRINIDAD-1922 In Facelets, Partial Refreshing <tr:inputText> Not Working

Workaround using of using getClientId() in the PPR Response

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java?rev=1054027&r1=1054026&r2=1054027&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java Thu Dec 30 23:58:05 2010
@@ -26,6 +26,8 @@ import javax.faces.component.UIComponent
 import javax.faces.component.UIForm;
 import javax.faces.context.FacesContext;
 
+import javax.faces.render.Renderer;
+
 import org.apache.myfaces.trinidad.component.UIXForm;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.ComponentUtils;
@@ -217,6 +219,34 @@ public class RenderUtils
 
   }
 
+  /**
+   * Returns the clientId used by the renderer in place of the clientId used by the component.
+   * Certain renderers render their root element with a clientId that differs from the one
+   * used by the component.
+   * @param context FacesContent.
+   * @param component UIComponent.
+   * @return component clientId if the renderer clientId is null. Otherwise clientId used by 
+   * renderer.
+   */
+  public static String getRendererClientId(
+    FacesContext context, 
+    UIComponent component) 
+  {
+    String clientId = component.getClientId(context);
+    String family = component.getFamily();
+    String rendererType = component.getRendererType();
+    if (rendererType != null)
+    {
+      Renderer renderer = context.getRenderKit().getRenderer(family, rendererType);
+      if (renderer instanceof CoreRenderer)
+      {
+        CoreRenderer coreRenderer = (CoreRenderer) renderer;
+        String rendererClientId = coreRenderer.getClientId(context, component);
+        return rendererClientId == null ? clientId : rendererClientId;
+      }
+    }
+    return clientId;
+  }
 
   // This does NOT use findComponent
   // ComponentUtils.findRelativeComponent finds the component, whereas
@@ -300,6 +330,7 @@ public class RenderUtils
     }
     return colonCount;
   }
+  
   static private final TrinidadLogger _LOG =
     TrinidadLogger.createTrinidadLogger(RenderUtils.class);
 

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml?rev=1054027&r1=1054026&r2=1054027&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml (original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml Thu Dec 30 23:58:05 2010
@@ -139,18 +139,21 @@ function setFocus(event)
                 </tr:panelGroupLayout>
               </tr:panelGroupLayout>
             </tr:panelHeader>
+            
             <tr:panelHeader text="InputText Component using JSF 2.0 Ajax" id="phInput">
-              <tr:outputFormatted styleUsage="instruction"
-                                  value="Tests autoSubmitting text fields which is also wired to use JSF 2.0 Ajax."/>
               <tr:panelGroupLayout layout="horizontal" id="pgl20">
                 <f:facet name="separator">
-                  <tr:spacer height="10" id="sp20"/>
+                  <tr:spacer width="10" id="sp20"/>
                 </f:facet>
+
                 <tr:panelGroupLayout layout="vertical" id="pgl21">
                   <f:facet name="separator">
-                    <tr:spacer height="6" id="sp21"/>
+                    <tr:spacer height="10" id="sp21"/>
                   </f:facet>
                   <tr:outputFormatted styleUsage="instruction"
+                                      value="Tests autoSubmitting text fields which is also wired to use JSF 2.0 Ajax."/>
+
+                  <tr:outputFormatted styleUsage="instruction"
                                       value="tr:inputText with autoSubmit=true."
                                       id="of20"/>
                   <tr:inputText id="itxt1" autoSubmit="true"
@@ -173,10 +176,30 @@ function setFocus(event)
                                   value="#{partialDemoUtil.status.textValue}"
                                   valueChangeListener="#{partialDemoUtil.valueChanged}"/>
                   </tr:subform>
+                  
+                  <tr:outputFormatted styleUsage="instruction" 
+                                      value="tr:inputText with value set when button is clicked. (There are no updates 
+                                      shown on the right side panel.)"
+                                      id="of22"/>
+                  <tr:inputText label="Press button to partial refresh" value="#{requestScope.status}" partialTriggers="icb1 icb2"/>
+                  
+                  <tr:panelGroupLayout id="pgl22" layout="horizontal">
+                    <f:facet name="separator">
+                      <tr:spacer width="10" id="sp22"/>
+                    </f:facet>
+                    <tr:commandButton text="Refresh Input" partialSubmit="true" id="icb1">
+                      <tr:setActionListener from="Success" to="#{requestScope.status}"/>
+                    </tr:commandButton>
+                    <tr:commandButton text="Reset Input" partialSubmit="true" id="icb2">
+                      <tr:setActionListener from="" to="#{requestScope.status}"/>
+                    </tr:commandButton>
+                  </tr:panelGroupLayout>
+                  
                 </tr:panelGroupLayout>
-                <tr:panelGroupLayout id="pgl21" layout="vertical">
+                
+                <tr:panelGroupLayout id="pgl23" layout="vertical">
                   <f:facet name="separator">
-                    <tr:spacer height="6" id="sp22"/>
+                    <tr:spacer height="10" id="sp23"/>
                   </f:facet>
                   <tr:statusIndicator id="si3" />
                   <tr:panelLabelAndMessage label="Input entered: ">
@@ -187,6 +210,7 @@ function setFocus(event)
                 </tr:panelGroupLayout>
               </tr:panelGroupLayout>
             </tr:panelHeader>
+            
             <tr:panelHeader text="Radio Buttons">
               <tr:outputFormatted styleUsage="instruction"
                                   value="This demo shows a two sets of radio buttons which use autoSubmit. There is also an output component which is listening on updates to the radio buttons and displaying status text accordingly."/>

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java?rev=1054027&r1=1054026&r2=1054027&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java Thu Dec 30 23:58:05 2010
@@ -36,6 +36,7 @@ import org.apache.myfaces.trinidad.conte
 import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
+import org.apache.myfaces.trinidad.render.RenderUtils;
 import org.apache.myfaces.trinidad.util.Service;
 
 import org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator;
@@ -452,9 +453,10 @@ public class PPRResponseWriter extends S
       if (component != null)
       {
         String clientId = component.getClientId(_facesContext);
+        String renderedClientId = RenderUtils.getRendererClientId(_facesContext, component);
         if (_state.pprContext.isPartialTarget(clientId))
         {
-          tag = new PPRTag(clientId);
+          tag = new PPRTag(clientId, renderedClientId);
           _state.enteringPPR = component;
         }
       }
@@ -563,9 +565,10 @@ public class PPRResponseWriter extends S
   //
   private class PPRTag
   {
-    public PPRTag(String id)
+    private PPRTag(String id, String renderedId)
     {
       _id = id;
+      _renderedId = renderedId != null ? renderedId : id;
     }
 
     public void startUpdate(
@@ -577,7 +580,7 @@ public class PPRResponseWriter extends S
         _startChanges();
         pprContext.pushRenderedPartialTarget(_id);
         _xml.startElement(_ELEMENT_CHANGES_UPDATE, null);
-        _xml.writeAttribute(_ATTRIBUTE_ID, _id, null);
+        _xml.writeAttribute(_ATTRIBUTE_ID, _renderedId, null);
         _xml.write("<![CDATA[");
         _xml.flush(); // NEW
 
@@ -655,6 +658,7 @@ public class PPRResponseWriter extends S
     }
     
     private String _id;
+    private String _renderedId;
   }