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:39 UTC
svn commit: r1634160 - in /myfaces/core/trunk/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:39 2014
New Revision: 1634160
URL: http://svn.apache.org/r1634160
Log:
MYFACES-3931 RelocatableResourceHandler tag + inner f:facet = NullPointerException
Added:
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/resources/js/b.js (with props)
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java?rev=1634160&r1=1634159&r2=1634160&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java Fri Oct 24 23:27:39 2014
@@ -341,6 +341,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/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java?rev=1634160&r1=1634159&r2=1634160&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java Fri Oct 24 23:27:39 2014
@@ -389,6 +389,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;
+ }
}
ComponentSupport.setCachedFacesContext(c, facesContext);
}
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/resources/js/b.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/resources/js/b.js?rev=1634160&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/resources/js/b.js (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/resources/js/b.js Fri Oct 24 23:27:39 2014
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2012 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+var x = "X";
\ No newline at end of file
Propchange: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/resources/js/b.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml?rev=1634160&r1=1634159&r2=1634160&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/impl/test_conditional_include_resources.xhtml Fri Oct 24 23:27:39 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">