<< http://java.net/jira/browse/GLASSFISH-18007 >> SECTION: Modified Files ---------------------------- M jsf-api/src/main/java/javax/faces/application/ViewHandler.java ---- initView method: check if we already have a character encoding before ---- calculating and setting another one. M jsf-ri/src/main/java/com/sun/faces/application/view/MultiViewHandler.java ---- initView method: Let the parent ViewHandler check if a character encoding has ---- already been set. This is because there may be custom ViewHandler implementations ---- that bypass MultiViewHandler. For example, the GlassFish Administration Console's ---- LayoutViewHandler extends ViewHandler. M jsf-test/build.xml ---- Added new test (below) A jsf-test/GLASSFISH-18007 A jsf-test/GLASSFISH-18007/htmlunit A jsf-test/GLASSFISH-18007/htmlunit/src A jsf-test/GLASSFISH-18007/htmlunit/src/main A jsf-test/GLASSFISH-18007/htmlunit/src/main/java A jsf-test/GLASSFISH-18007/htmlunit/src/main/java/com A jsf-test/GLASSFISH-18007/htmlunit/src/main/java/com/sun A jsf-test/GLASSFISH-18007/htmlunit/src/main/java/com/sun/faces A jsf-test/GLASSFISH-18007/htmlunit/src/main/java/com/sun/faces/systest A jsf-test/GLASSFISH-18007/htmlunit/src/main/java/com/sun/faces/systest/IssueGF18007TestCase.java A jsf-test/GLASSFISH-18007/htmlunit/pom.xml A jsf-test/GLASSFISH-18007/i_glassfish_18007 A jsf-test/GLASSFISH-18007/i_glassfish_18007/src A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007 A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007/TestBean.java A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007/TestViewHandler.java A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF/faces-config.xml A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF/web.xml A jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/Test.xhtml A jsf-test/GLASSFISH-18007/i_glassfish_18007/pom.xml A jsf-test/GLASSFISH-18007/build.xml ---- Test Module utilizes a custom ViewHandler whose initView method sets the character encoding. ---- The test module ensures that the character coding set there, has not been overridden ---- by the parent ViewHandler. SECTION: Diffs ---------------------------- Index: jsf-api/src/main/java/javax/faces/application/ViewHandler.java =================================================================== --- jsf-api/src/main/java/javax/faces/application/ViewHandler.java (revision 9566) +++ jsf-api/src/main/java/javax/faces/application/ViewHandler.java (working copy) @@ -482,8 +482,12 @@ */ public void initView(FacesContext context) throws FacesException { - String encoding = calculateCharacterEncoding(context); + String encoding = context.getExternalContext().getRequestCharacterEncoding(); if (null != encoding) { + return; + } + encoding = calculateCharacterEncoding(context); + if (null != encoding) { try { context.getExternalContext().setRequestCharacterEncoding(encoding); } catch (UnsupportedEncodingException e) { Index: jsf-ri/src/main/java/com/sun/faces/application/view/MultiViewHandler.java =================================================================== --- jsf-ri/src/main/java/com/sun/faces/application/view/MultiViewHandler.java (revision 9566) +++ jsf-ri/src/main/java/com/sun/faces/application/view/MultiViewHandler.java (working copy) @@ -98,19 +98,13 @@ /** - * Do not call the default implementation of {@link javax.faces.application.ViewHandler#initView(javax.faces.context.FacesContext)} - * if the {@link javax.faces.context.ExternalContext#getRequestCharacterEncoding()} returns a - * non-null result. + * Call the default implementation of {@link javax.faces.application.ViewHandler#initView(javax.faces.context.FacesContext)} * * @see javax.faces.application.ViewHandler#initView(javax.faces.context.FacesContext) */ @Override public void initView(FacesContext context) throws FacesException { - - if (context.getExternalContext().getRequestCharacterEncoding() == null) { - super.initView(context); - } - + super.initView(context); } Index: jsf-test/build.xml =================================================================== --- jsf-test/build.xml (revision 9566) +++ jsf-test/build.xml (working copy) @@ -86,7 +86,8 @@ JAVASERVERFACES-2258, JAVASERVERFACES-2266, JAVASERVERFACES-2255, - JAVASERVERFACES-2232" /> + JAVASERVERFACES-2232, + GLASSFISH-18007" /> Index: jsf-test/GLASSFISH-18007/htmlunit/src/main/java/com/sun/faces/systest/IssueGF18007TestCase.java =================================================================== --- jsf-test/GLASSFISH-18007/htmlunit/src/main/java/com/sun/faces/systest/IssueGF18007TestCase.java (revision 0) +++ jsf-test/GLASSFISH-18007/htmlunit/src/main/java/com/sun/faces/systest/IssueGF18007TestCase.java (revision 0) @@ -0,0 +1,87 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package com.sun.faces.systest; + +import com.gargoylesoftware.htmlunit.html.HtmlTextInput; +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput; + +import com.sun.faces.htmlunit.HtmlUnitFacesTestCase; + +import javax.faces.component.NamingContainer; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class IssueGF18007TestCase extends HtmlUnitFacesTestCase { + + public IssueGF18007TestCase(String name) { + super(name); + } + + /** + * Set up instance variables required by this test case. + */ + @Override + public void setUp() throws Exception { + super.setUp(); + } + + /** + * Return the tests included in this test suite. + */ + public static Test suite() { + return (new TestSuite(IssueGF18007TestCase.class)); + } + + /** + * Tear down instance variables required by this test case. + */ + @Override + public void tearDown() { + super.tearDown(); + } + + // ------------------------------------------------------------ Test Methods + public void testCharEncoding() throws Exception { + HtmlPage page = getPage("/faces/Test.xhtml"); + assertTrue(page.asText().contains("ISO-8859-1")); + } +} Index: jsf-test/GLASSFISH-18007/htmlunit/pom.xml =================================================================== --- jsf-test/GLASSFISH-18007/htmlunit/pom.xml (revision 0) +++ jsf-test/GLASSFISH-18007/htmlunit/pom.xml (revision 0) @@ -0,0 +1,116 @@ + + + + + 4.0.0 + com.sun.faces.test + i_glassfish_18007_htmlunit + jar + i_glassfish_18007_htmlunit + 2.0 + + Test for Issue #2258 + + + + + htmlunit + net.sourceforge.htmlunit + 2.4 + provided + + + junit + junit + 3.8.1 + provided + + + com.sun.faces.extensions + jsf-extensions-test-time + 2.0 + provided + + + javax + javaee-api + 6.0 + provided + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + maven-war-plugin + org.apache.maven.plugins + 2.1-alpha-2 + + false + + + + + i_glassfish_18007_htmlunit + + + + + java.net + java.net + http://download.java.net/maven/2 + default + + + + Index: jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007/TestBean.java =================================================================== --- jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007/TestBean.java (revision 0) +++ jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007/TestBean.java (revision 0) @@ -0,0 +1,56 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +// TestBean.java + +package i_glassfish_18007; + +import javax.faces.bean.ManagedBean; +import javax.faces.context.FacesContext; + +@ManagedBean(name = "testbean") +public class TestBean { + + public String getEncoding() { + FacesContext context = FacesContext.getCurrentInstance(); + return context.getExternalContext().getRequestCharacterEncoding(); + } +} + Index: jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007/TestViewHandler.java =================================================================== --- jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007/TestViewHandler.java (revision 0) +++ jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/java/i_glassfish_18007/TestViewHandler.java (revision 0) @@ -0,0 +1,73 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +// TestViewHandler.java + +package i_glassfish_18007; + +import java.io.UnsupportedEncodingException; +import javax.faces.FacesException; +import javax.faces.application.ViewHandler; +import javax.faces.application.ViewHandlerWrapper; +import javax.faces.context.FacesContext; + +public class TestViewHandler extends ViewHandlerWrapper { + + private ViewHandler wrapped; + + public TestViewHandler(ViewHandler wrapped) { + this.wrapped = wrapped; + } + + @Override + public ViewHandler getWrapped() { + return wrapped; + } + + @Override + public void initView(FacesContext context) throws FacesException { + try { + context.getExternalContext().setRequestCharacterEncoding("ISO-8859-1"); + } catch (UnsupportedEncodingException e) { + } + wrapped.initView(context); + } +} + Index: jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF/faces-config.xml =================================================================== --- jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF/faces-config.xml (revision 0) +++ jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF/faces-config.xml (revision 0) @@ -0,0 +1,53 @@ + + + + + + + i_glassfish_18007.TestViewHandler + + + Index: jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF/web.xml =================================================================== --- jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF/web.xml (revision 0) +++ jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/WEB-INF/web.xml (revision 0) @@ -0,0 +1,72 @@ + + + + + TestJSFServlet + + + com.sun.faces.config.ConfigureListener + + + + + FacesServlet + javax.faces.webapp.FacesServlet + -1 + + + + + + javax.faces.PROJECT_STAGE + Development + + + + FacesServlet + /faces/* + + + Index: jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/Test.xhtml =================================================================== --- jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/Test.xhtml (revision 0) +++ jsf-test/GLASSFISH-18007/i_glassfish_18007/src/main/webapp/Test.xhtml (revision 0) @@ -0,0 +1,56 @@ + + + + +test page + + + + + + + Index: jsf-test/GLASSFISH-18007/i_glassfish_18007/pom.xml =================================================================== --- jsf-test/GLASSFISH-18007/i_glassfish_18007/pom.xml (revision 0) +++ jsf-test/GLASSFISH-18007/i_glassfish_18007/pom.xml (revision 0) @@ -0,0 +1,111 @@ + + + + + 4.0.0 + + com.sun.faces.test + i_glassfish_18007 + 1.0 + war + + i_glassfish_18007 + + + maven-compiler-plugin + + 1.6 + 1.6 + + + + maven-dependency-plugin + + + install + + + + + + + + + + + org.jvnet.wagon-svn + wagon-svn + 1.12 + + + + + + javax + javaee-api + 6.0 + provided + + + + + + + false + java.net-maven2-repository + java-net:/maven2-repository~svn/trunk/repository/ + + + + + + java.net + java.net + http://download.java.net/maven/2 + default + + + + + Index: jsf-test/GLASSFISH-18007/build.xml =================================================================== --- jsf-test/GLASSFISH-18007/build.xml (revision 0) +++ jsf-test/GLASSFISH-18007/build.xml (revision 0) @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SECTION: New Files ---------------------------- SEE ATTACHMENTS