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 2013/09/26 10:57:55 UTC
svn commit: r1526423 - in /myfaces/core/trunk/impl/src:
main/java/org/apache/myfaces/view/facelets/compiler/
test/java/org/apache/myfaces/view/facelets/
test/java/org/apache/myfaces/view/facelets/bean/
test/resources/org/apache/myfaces/view/facelets/
Author: lu4242
Date: Thu Sep 26 08:57:55 2013
New Revision: 1526423
URL: http://svn.apache.org/r1526423
Log:
MYFACES-3781 f:view tag must be processed when view metadata is created
Added:
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/bean/ViewBean.java
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter2.xhtml
- copied, changed from r1525536, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter1.xhtml
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java?rev=1526423&r1=1526422&r2=1526423&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java Thu Sep 26 08:57:55 2013
@@ -369,9 +369,16 @@ public final class SAXCompiler extends C
this.unit.popTag();
}
if ( (CoreLibrary.NAMESPACE.equals(uri) ||
- CoreLibrary.ALIAS_NAMESPACE.equals(uri)) && "metadata".equals(localName))
+ CoreLibrary.ALIAS_NAMESPACE.equals(uri)))
{
- this.inMetadata=false;
+ if ("metadata".equals(localName))
+ {
+ this.inMetadata=false;
+ }
+ else if (!inMetadata && "view".equals(localName))
+ {
+ this.unit.popTag();
+ }
}
}
@@ -449,10 +456,17 @@ public final class SAXCompiler extends C
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
{
- if ( (CoreLibrary.NAMESPACE.equals(uri) ||
- CoreLibrary.ALIAS_NAMESPACE.equals(uri)) && "metadata".equals(localName))
+ if ( CoreLibrary.NAMESPACE.equals(uri) ||
+ CoreLibrary.ALIAS_NAMESPACE.equals(uri))
{
- this.inMetadata=true;
+ if ("metadata".equals(localName))
+ {
+ this.inMetadata=true;
+ }
+ else if (!inMetadata && "view".equals(localName))
+ {
+ this.unit.pushTag(new Tag(createLocation(), uri, localName, qName, createAttributes(attributes)));
+ }
}
if (inMetadata)
{
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java?rev=1526423&r1=1526422&r2=1526423&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java Thu Sep 26 08:57:55 2013
@@ -18,6 +18,7 @@
*/
package org.apache.myfaces.view.facelets;
+import java.util.Locale;
import org.junit.Assert;
import org.junit.Test;
@@ -26,6 +27,7 @@ import javax.faces.component.UIPanel;
import javax.faces.component.UIViewParameter;
import javax.faces.component.UIViewRoot;
import javax.faces.view.ViewMetadata;
+import org.apache.myfaces.view.facelets.bean.ViewBean;
/**
* Test cases for FaceletViewDeclarationLanguage.
@@ -69,4 +71,26 @@ public class FaceletViewDeclarationLangu
Assert.assertTrue(viewParameter instanceof UIViewParameter);
}
+ @Test
+ public void testBuildViewUIViewParametersLocale() throws Exception
+ {
+ request.setAttribute("viewBean", new ViewBean());
+
+ // build a UIViewRoot with a UIViewParameter
+ ViewMetadata viewMetadata = this.vdl.getViewMetadata(facesContext, "viewparameter2.xhtml");
+ UIViewRoot root = viewMetadata.createMetadataView(facesContext);
+ facesContext.setViewRoot(root);
+
+ // UIViewParameter must be there
+ checkUIViewParameter(root);
+
+ Assert.assertEquals(Locale.FRANCE, root.getLocale());
+
+ // build and render view (must not remove UIViewParameter)
+ vdl.buildView(facesContext, root, "viewparameter2.xhtml");
+ vdl.renderView(facesContext, root);
+
+ // UIViewParameter must still be there, because its value is saved in the state!
+ checkUIViewParameter(root);
+ }
}
Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/bean/ViewBean.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/bean/ViewBean.java?rev=1526423&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/bean/ViewBean.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/bean/ViewBean.java Thu Sep 26 08:57:55 2013
@@ -0,0 +1,73 @@
+/*
+ * 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.bean;
+
+import java.util.Locale;
+
+/**
+ *
+ * @author Leonardo Uribe
+ */
+public class ViewBean
+{
+ private String input;
+
+ private Locale locale;
+
+ public ViewBean()
+ {
+ locale = Locale.FRANCE;
+ }
+ /**
+ * @return the input
+ */
+ public String getInput()
+ {
+ return input;
+ }
+
+ /**
+ * @param input the input to set
+ */
+ public void setInput(String input)
+ {
+ this.input = input;
+ }
+
+ /**
+ * @return the locale
+ */
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ /**
+ * @param locale the locale to set
+ */
+ public void setLocale(Locale locale)
+ {
+ this.locale = locale;
+ }
+
+ public String action()
+ {
+ return null;
+ }
+}
Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter2.xhtml (from r1525536, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter2.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter2.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter1.xhtml&r1=1525536&r2=1526423&rev=1526423&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/viewparameter2.xhtml Thu Sep 26 08:57:55 2013
@@ -21,7 +21,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
-
+<f:view locale="#{viewBean.locale}">
<f:metadata>
<f:viewParam name="input" value="#{viewBean.input}" />
</f:metadata>
@@ -42,4 +42,5 @@
</h:form>
</h:body>
+</f:view>
</html>