You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/12/01 05:17:30 UTC

svn commit: r885666 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html: HtmlScriptRenderer.java HtmlStylesheetRenderer.java

Author: lu4242
Date: Tue Dec  1 04:17:28 2009
New Revision: 885666

URL: http://svn.apache.org/viewvc?rev=885666&view=rev
Log:
MYFACES-2428 Id generation for facelets cause problems with htmlunit 2.4 or lower

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java?rev=885666&r1=885665&r2=885666&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java Tue Dec  1 04:17:28 2009
@@ -73,15 +73,18 @@
         {
             FacesContext facesContext = FacesContext.getCurrentInstance();
             
-            UniqueIdVendor uiv = findParentUniqueIdVendor(component);
-            
-            if (! (uiv instanceof UIViewRoot))
+            if (component.getId() != null)
             {
-                // The id was set using the closest UniqueIdVendor, but since this one
-                // will be relocated, we need to assign an id from the current root.
-                // otherwise a duplicate id exception could happen.
-                component.setId(facesContext.getViewRoot().createUniqueId(facesContext, null));
-            }            
+                UniqueIdVendor uiv = findParentUniqueIdVendor(component);
+
+                if ( (!(uiv instanceof UIViewRoot)) && component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
+                {
+                    // The id was set using the closest UniqueIdVendor, but since this one
+                    // will be relocated, we need to assign an id from the current root.
+                    // otherwise a duplicate id exception could happen.
+                    component.setId(facesContext.getViewRoot().createUniqueId(facesContext, null));
+                }
+            }
 
             facesContext.getViewRoot().addComponentResource(facesContext,
                     component, target);

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java?rev=885666&r1=885665&r2=885666&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java Tue Dec  1 04:17:28 2009
@@ -70,14 +70,17 @@
         UIComponent component = event.getComponent();
         FacesContext facesContext = FacesContext.getCurrentInstance();
         
-        UniqueIdVendor uiv = findParentUniqueIdVendor(component);
-        
-        if (! (uiv instanceof UIViewRoot))
+        if (component.getId() != null)
         {
-            // The id was set using the closest UniqueIdVendor, but since this one
-            // will be relocated, we need to assign an id from the current root.
-            // otherwise a duplicate id exception could happen.
-            component.setId(facesContext.getViewRoot().createUniqueId(facesContext, null));
+            UniqueIdVendor uiv = findParentUniqueIdVendor(component);
+            
+            if ( (!(uiv instanceof UIViewRoot)) && component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
+            {
+                // The id was set using the closest UniqueIdVendor, but since this one
+                // will be relocated, we need to assign an id from the current root.
+                // otherwise a duplicate id exception could happen.
+                component.setId(facesContext.getViewRoot().createUniqueId(facesContext, null));
+            }
         }
         
         facesContext.getViewRoot().addComponentResource(facesContext,