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 2014/10/25 01:27:17 UTC
svn commit: r1634159 - in /myfaces/core/branches/2.1.x/impl/src:
main/java/org/apache/myfaces/view/facelets/tag/jsf/
test/resources/org/apache/myfaces/view/facelets/impl/
test/resources/org/apache/myfaces/view/facelets/impl/resources/js/
Author: lu4242
Date: Fri Oct 24 23:27:17 2014
New Revision: 1634159
URL: http://svn.apache.org/r1634159
Log:
MYFACES-3931 RelocatableResourceHandler tag + inner f:facet = NullPointerException
Added:
myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/resources/js/b.js
- copied unchanged from r1633413, myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/resources/js/x.js
Modified:
myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml
Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java?rev=1634159&r1=1634158&r2=1634159&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java Fri Oct 24 23:27:17 2014
@@ -206,6 +206,70 @@ public final class ComponentSupport
return null;
}
+
+ public static UIComponent findChildInChildrenByTagId(UIComponent parent, String id)
+ {
+ if (parent.getChildCount() > 0)
+ {
+ for (int i = 0, childCount = parent.getChildCount(); i < childCount; i ++)
+ {
+ UIComponent child = parent.getChildren().get(i);
+ if (id.equals(child.getAttributes().get(MARK_CREATED)))
+ {
+ return child;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String findChildInFacetsByTagId(UIComponent parent, String id)
+ {
+ Iterator<Map.Entry<String, UIComponent>> itr = null;
+ if (parent.getFacetCount() > 0)
+ {
+ itr = parent.getFacets().entrySet().iterator();
+ while (itr.hasNext())
+ {
+ Map.Entry<String, UIComponent> entry = itr.next();
+ UIComponent facet = entry.getValue();
+ // check if this is a dynamically generated UIPanel
+ if (Boolean.TRUE.equals(facet.getAttributes()
+ .get(FACET_CREATED_UIPANEL_MARKER)))
+ {
+ // only check the children and facets of the panel
+ if (facet.getChildCount() > 0)
+ {
+ for (int i = 0, childCount = facet.getChildCount(); i < childCount; i ++)
+ {
+ UIComponent child = facet.getChildren().get(i);
+ if (id.equals(child.getAttributes().get(MARK_CREATED)))
+ {
+ return entry.getKey();
+ }
+ }
+ }
+ if (facet.getFacetCount() > 0)
+ {
+ Iterator<UIComponent> itr2 = facet.getFacets().values().iterator();
+ while (itr2.hasNext())
+ {
+ UIComponent child = itr2.next();
+ if (id.equals(child.getAttributes().get(MARK_CREATED)))
+ {
+ return entry.getKey();
+ }
+ }
+ }
+ }
+ else if (id.equals(facet.getAttributes().get(MARK_CREATED)))
+ {
+ return entry.getKey();
+ }
+ }
+ }
+ return null;
+ }
/**
* According to JSF 1.2 tag specs, this helper method will use the TagAttribute passed in determining the Locale
Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java?rev=1634159&r1=1634158&r2=1634159&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java Fri Oct 24 23:27:17 2014
@@ -325,6 +325,18 @@ public class ComponentTagHandlerDelegate
{
// Replace parent with the relocated parent.
parent = c.getParent();
+ // Since we changed the parent, the facetName becomes invalid, because it points
+ // to the component before relocation. We need to find the right facetName (if any) so we can
+ // refresh the component properly.
+ UIComponent c1 = ComponentSupport.findChildInChildrenByTagId(parent, id);
+ if (c1 == null)
+ {
+ facetName = ComponentSupport.findChildInFacetsByTagId(parent, id);
+ }
+ else
+ {
+ facetName = null;
+ }
}
}
if (facetName == null)
Modified: myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml?rev=1634159&r1=1634158&r2=1634159&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml (original)
+++ myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml Fri Oct 24 23:27:17 2014
@@ -19,6 +19,9 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head id="head">
+ <f:facet name="first">
+ <h:outputScript name="b.js" target="body"/>
+ </f:facet>
</h:head>
<h:body id="body">