You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2005/05/04 07:45:05 UTC

svn commit: r168076 - /struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java

Author: craigmcc
Date: Tue May  3 22:45:04 2005
New Revision: 168076

URL: http://svn.apache.org/viewcvs?rev=168076&view=rev
Log:
Deal with problems on components that do not have a specified id not matching
on a postback.

PR:  Bugzilla #34711
Submitted by:  Manfred Klug <manklu AT web.de>

Modified:
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java?rev=168076&r1=168075&r2=168076&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java Tue May  3 22:45:04 2005
@@ -132,7 +132,24 @@
      * </p>
      */
     private ComponentBean displayElementRoot = null;
+
+    /**
+     * <p>
+     * The output from UIViewRoot.createUniqueId() after the
+     * component tree has been constructed.
+     */
+    private String lastUniqueId = null;
     
+    public void setlastUniqueId(String newId)
+    {
+        lastUniqueId = newId;
+    }
+
+    public String getlastUniqueId()
+    {
+        return lastUniqueId;
+    }
+
     /**
      * <p>
      * Returns the unique identifier used to build the component subtree
@@ -228,7 +245,16 @@
         if (log.isTraceEnabled())
             log.trace("encodeBegin(FacesContext)");
         
-        if (getDisplayElementRoot() == null) {
+        if (getDisplayElementRoot() != null) {
+            // Call UIViewRoot.createUniqueId() until we have reproduced all
+            // IDs used during construction.
+            String currId = getFacesContext().getViewRoot().createUniqueId();
+            String lastId = this.getlastUniqueId();
+            while(!lastId.equals(currId)) {
+                currId = getFacesContext().getViewRoot().createUniqueId();
+            }
+        }
+        else {
             if (!getJsfid().equals(Globals.RUNTIME_ELEMENT_ID)) {
                 displayElementRoot = getRootElement();
             } else {
@@ -301,6 +327,8 @@
                 throw new RuntimeException(e);
             }
             
+            setlastUniqueId(getFacesContext().getViewRoot().createUniqueId());
+            
         }
         
         super.encodeBegin(context);
@@ -402,6 +430,7 @@
         managedBeanName = ((String) aobj[2]);
         shapeValidator = ((String) aobj[3]);
         displayElementRoot = ((ComponentBean) aobj[4]);
+        lastUniqueId = ((String)aobj[5]);
         
     }
     
@@ -413,12 +442,13 @@
      * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
      */
     public Object saveState(FacesContext context) {
-        Object[] aobj = new Object[5];
+        Object[] aobj = new Object[6];
         aobj[0] = super.saveState(context);
         aobj[1] = jsfid;
         aobj[2] = managedBeanName;
         aobj[3] = shapeValidator;
         aobj[4] = displayElementRoot;
+        aobj[5] = lastUniqueId;
         
         return aobj;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org