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/09/19 01:06:59 UTC
svn commit: r816808 - in /myfaces/core/trunk:
api/src/main/java/javax/faces/component/
impl/src/main/java/org/apache/myfaces/resource/
impl/src/test/java/org/apache/myfaces/view/facelets/mock/
impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf...
Author: lu4242
Date: Fri Sep 18 23:06:57 2009
New Revision: 816808
URL: http://svn.apache.org/viewvc?rev=816808&view=rev
Log:
MYFACES-2225 Implement PostAddToViewEvent and PreRemoveFromViewEvent thrown conditions
Added:
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputScriptTestCase.java (with props)
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/javax.faces/
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/javax.faces/jsf.js
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testMultipleTargetHeadOutputScript.xhtml
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleOutputScript.xhtml
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleTargetHeadOutputScript.xhtml
Modified:
myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java
Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java?rev=816808&r1=816807&r2=816808&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java Fri Sep 18 23:06:57 2009
@@ -247,9 +247,26 @@
if (component.getChildCount() > 0)
{
- for (UIComponent child : component.getChildren())
- {
- _publishPostAddToViewEvent(context, child);
+ // PostAddToViewEvent could cause component relocation
+ // (h:outputScript, h:outputStylesheet, composite:insertChildren, composite:insertFacet)
+ // so we need to check if the component was relocated or not
+ List<UIComponent> children = component.getChildren();
+ UIComponent child = null;
+ UIComponent currentChild = null;
+ int i = 0;
+ while (i < children.size())
+ {
+ child = children.get(i);
+ // Iterate over the same index if the component was removed
+ // This prevents skip components when processing
+ do
+ {
+ _publishPostAddToViewEvent(context, child);
+ currentChild = child;
+ }
+ while ((i < children.size()) &&
+ ((child = children.get(i)) != currentChild) );
+ i++;
}
}
if (component.getFacetCount() > 0)
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java?rev=816808&r1=816807&r2=816808&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java Fri Sep 18 23:06:57 2009
@@ -191,8 +191,9 @@
}
else
{
- path = _resourceHandlerSupport.getMapping() +
- ResourceHandler.RESOURCE_IDENTIFIER + '/' + getResourceName();
+ String mapping = _resourceHandlerSupport.getMapping();
+ path = ResourceHandler.RESOURCE_IDENTIFIER + '/' + getResourceName();
+ path = (mapping == null) ? path : mapping + path;
}
String metadata = null;
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java?rev=816808&r1=816807&r2=816808&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java Fri Sep 18 23:06:57 2009
@@ -59,7 +59,6 @@
private String getDirectory()
{
return _referenceClass.getName().substring(0,
- _referenceClass.getName().lastIndexOf('.')).replace('.', '/')
- + "/";
+ _referenceClass.getName().lastIndexOf('.')).replace('.', '/');
}
}
Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputScriptTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputScriptTestCase.java?rev=816808&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputScriptTestCase.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputScriptTestCase.java Fri Sep 18 23:06:57 2009
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.myfaces.view.facelets.tag.jsf.html;
+
+import java.io.StringWriter;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UIViewRoot;
+
+import org.apache.myfaces.view.facelets.FaceletTestCase;
+import org.apache.shale.test.mock.MockResponseWriter;
+
+public class HtmlOutputScriptTestCase extends FaceletTestCase
+{
+ public void testSimpleOutputScript() throws Exception
+ {
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root, "testSimpleOutputScript.xhtml");
+
+ UIComponent head = root.findComponent("head");
+ assertNotNull(head);
+ UIComponent body = root.findComponent("body");
+ assertNotNull(body);
+
+ StringWriter sw = new StringWriter();
+ MockResponseWriter mrw = new MockResponseWriter(sw);
+ facesContext.setResponseWriter(mrw);
+
+ root.encodeAll(facesContext);
+ sw.flush();
+ //System.out.print(sw.toString());
+ }
+
+ public void testSimpleTargetHeadOutputScript() throws Exception
+ {
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root, "testSimpleTargetHeadOutputScript.xhtml");
+
+ UIComponent head = root.findComponent("head");
+ assertNotNull(head);
+ UIComponent body = root.findComponent("body");
+ assertNotNull(body);
+
+ StringWriter sw = new StringWriter();
+ MockResponseWriter mrw = new MockResponseWriter(sw);
+ facesContext.setResponseWriter(mrw);
+
+ root.encodeAll(facesContext);
+ sw.flush();
+ //System.out.print(sw.toString());
+ }
+
+ public void testMultipleTargetHeadOutputScript() throws Exception
+ {
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root, "testMultipleTargetHeadOutputScript.xhtml");
+
+ UIComponent head = root.findComponent("head");
+ assertNotNull(head);
+ UIComponent body = root.findComponent("body");
+ assertNotNull(body);
+
+ StringWriter sw = new StringWriter();
+ MockResponseWriter mrw = new MockResponseWriter(sw);
+ facesContext.setResponseWriter(mrw);
+
+ root.encodeAll(facesContext);
+ sw.flush();
+ //System.out.print(sw.toString());
+ }
+}
Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputScriptTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputScriptTestCase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/javax.faces/jsf.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/javax.faces/jsf.js?rev=816808&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/javax.faces/jsf.js (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/javax.faces/jsf.js Fri Sep 18 23:06:57 2009
@@ -0,0 +1 @@
+//Dummy class to make work h:outputScript
\ No newline at end of file
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testMultipleTargetHeadOutputScript.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testMultipleTargetHeadOutputScript.xhtml?rev=816808&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testMultipleTargetHeadOutputScript.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testMultipleTargetHeadOutputScript.xhtml Fri Sep 18 23:06:57 2009
@@ -0,0 +1,30 @@
+<!--
+ 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.
+
+ $Id: defineInclude.xml 804043 2009-08-13 22:08:44Z lu4242 $
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+<h:head id="head">
+ <h:outputScript name="jsf.js" library="javax.faces"/>
+ <h:outputScript name="jsf.js" library="javax.faces" target="body"/>
+</h:head>
+<h:body id="body">
+ <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
+ <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
+ <h:outputText value="" />
+ <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
+</h:body>
+</html>
\ No newline at end of file
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleOutputScript.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleOutputScript.xhtml?rev=816808&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleOutputScript.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleOutputScript.xhtml Fri Sep 18 23:06:57 2009
@@ -0,0 +1,25 @@
+<!--
+ 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.
+
+ $Id: defineInclude.xml 804043 2009-08-13 22:08:44Z lu4242 $
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+<h:head id="head">
+ <h:outputScript name="jsf.js" library="javax.faces"/>
+</h:head>
+<h:body id="body">
+</h:body>
+</html>
\ No newline at end of file
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleTargetHeadOutputScript.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleTargetHeadOutputScript.xhtml?rev=816808&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleTargetHeadOutputScript.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testSimpleTargetHeadOutputScript.xhtml Fri Sep 18 23:06:57 2009
@@ -0,0 +1,26 @@
+<!--
+ 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.
+
+ $Id: defineInclude.xml 804043 2009-08-13 22:08:44Z lu4242 $
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+<h:head id="head">
+</h:head>
+<h:body id="body">
+ <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
+ <h:outputText value="" />
+</h:body>
+</html>
\ No newline at end of file