dev@javaserverfaces.java.net

Re: [mojarra~git:22fb7da2] JAVASERVERFACES-4092 - [Port 2.1] JAVASERVERFACES-3031 not fixed when usi

From: manfred riem <manfred.riem_at_oracle.com>
Date: Thu, 14 Jan 2016 09:23:16 -0600

Hi Vernon,

I assume you made sure all the tests pass locally before committing?

Thanks!

Kind regards,
Manfred Riem

On 1/12/16, 12:33 PM, vsingleton_at_java.net wrote:
> Project: mojarra
> Repository: git
> Revision: 22fb7da2ff9a1140c9342a967f1a4e39582849cf
> Author: vsingleton
> Date: 2016-01-12 18:26:36 UTC
> Link:
>
> Log Message:
> ------------
> JAVASERVERFACES-4092 - [Port 2.1] JAVASERVERFACES-3031 not fixed when using f:param without AJAX
>
>
>
> Revisions:
> ----------
> 22fb7da2ff9a1140c9342a967f1a4e39582849cf
>
>
> Modified Paths:
> ---------------
> jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
> test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/UserBean.java
> test/agnostic/ajax-namespace/src/main/webapp/WEB-INF/faces-config.xml
> test/agnostic/ajax-namespace/src/main/webapp/index.xhtml
> test/agnostic/ajax-namespace/src/test/java/com/sun/faces/test/agnostic/ajax_namespace/Issue3031IT.java
>
>
> Added Paths:
> ------------
> test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/ExternalContextFactoryImpl.java
> test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/ExternalContextNamespaceImpl.java
> test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/NamespacedRequestParameterMap.java
>
>
> Diffs:
> ------
> --- a/jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
> +++ b/jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
> @@ -65,6 +65,8 @@ import javax.faces.render.ResponseStateManager;
> import javax.faces.render.Renderer;
>
> import com.sun.faces.RIConstants;
> +import com.sun.faces.config.WebConfiguration;
> +import com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter;
> import com.sun.faces.facelets.util.DevTools;
> import com.sun.faces.util.FacesLogger;
> import com.sun.faces.util.Util;
> @@ -151,7 +153,7 @@ public class RenderKitUtils {
>
>
> protected static final Logger LOGGER = FacesLogger.RENDERKIT.getLogger();
> -
> +
>
> // ------------------------------------------------------------ Constructors
>
> @@ -1562,8 +1564,21 @@ public class RenderKitUtils {
> appendProperty(builder, componentClientId, componentClientId);
>
> if ((null != params)&& (!params.isEmpty())) {
> +
> + String namingContainerId = "";
> +
> + WebConfiguration webConfig = WebConfiguration.getInstance();
> + boolean namespaceParameters = webConfig.isOptionEnabled(BooleanWebContextInitParameter.NamespaceParameters);
> +
> + if (namespaceParameters) {
> + UIViewRoot viewRoot = context.getViewRoot();
> + if (viewRoot instanceof NamingContainer) {
> + namingContainerId = viewRoot.getContainerClientId(context);
> + }
> + }
> +
> for (ClientBehaviorContext.Parameter param : params) {
> - appendProperty(builder, param.getName(), param.getValue());
> + appendProperty(builder, namingContainerId + param.getName(), param.getValue());
> }
> }
>
> --- /dev/null
> +++ b/test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/ExternalContextFactoryImpl.java
> @@ -0,0 +1,83 @@
> +/*
> + * 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.test.agnostic.ajax_namespace;
> +
> +import javax.faces.FacesException;
> +import javax.faces.application.Application;
> +import javax.faces.application.ApplicationFactory;
> +import javax.faces.context.ExternalContext;
> +import javax.faces.context.ExternalContextFactory;
> +import javax.servlet.ServletContext;
> +import javax.servlet.ServletRequest;
> +import javax.servlet.ServletResponse;
> +
> +import com.sun.faces.context.ExternalContextImpl;
> +
> +public class ExternalContextFactoryImpl extends ExternalContextFactory {
> + private final ExternalContextFactory parent;
> +
> + public ExternalContextFactoryImpl(ExternalContextFactory parent) {
> + this.parent = parent;
> + }
> +
> + @Override
> + public ExternalContextFactory getWrapped() {
> + return parent;
> + }
> +
> + public ExternalContext getExternalContext(Object context, Object request,
> + Object response) throws FacesException {
> + ExternalContext extContext = new ExternalContextNamespaceImpl(
> + new ExternalContextImpl((ServletContext) context,
> + (ServletRequest) request, (ServletResponse) response));
> +
> + if (request instanceof ServletRequest) {
> + ((ServletRequest) request)
> + .setAttribute(
> + com.sun.faces.context.ExternalContextFactoryImpl.DEFAULT_EXTERNAL_CONTEXT_KEY,
> + extContext);
> + }
> +
> + return extContext;
> + }
> +
> +}
> \ No newline at end of file
> --- /dev/null
> +++ b/test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/ExternalContextNamespaceImpl.java
> @@ -0,0 +1,75 @@
> +/*
> + * 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.test.agnostic.ajax_namespace;
> +
> +import java.util.Collections;
> +import java.util.Map;
> +
> +import javax.faces.context.ExternalContext;
> +import javax.faces.context.ExternalContextWrapper;
> +import javax.servlet.ServletRequest;
> +
> +import com.sun.faces.context.RequestParameterMap;
> +
> +public class ExternalContextNamespaceImpl extends ExternalContextWrapper {
> +
> + private final ExternalContext parent;
> + private Map<String, String> requestParameterMap = null;
> +
> + public ExternalContextNamespaceImpl(ExternalContext externalContext) {
> + parent = externalContext;
> + }
> +
> + public ExternalContext getWrapped() {
> + return parent;
> + }
> +
> + public Map<String, String> getRequestParameterMap() {
> + if (null == requestParameterMap) {
> + requestParameterMap = Collections
> + .unmodifiableMap(new NamespacedRequestParameterMap(
> + ((ServletRequest) getWrapped().getRequest())));
> + }
> + return requestParameterMap;
> + }
> +
> +}
> \ No newline at end of file
> --- /dev/null
> +++ b/test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/NamespacedRequestParameterMap.java
> @@ -0,0 +1,88 @@
> +/*
> + * 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.test.agnostic.ajax_namespace;
> +
> +import java.util.Collection;
> +import java.util.Collections;
> +import java.util.Iterator;
> +import java.util.Map;
> +import java.util.Set;
> +
> +import javax.servlet.ServletRequest;
> +
> +import com.sun.faces.context.RequestParameterMap;
> +import com.sun.faces.util.Util;
> +
> +public class NamespacedRequestParameterMap extends RequestParameterMap {
> +
> + private final ServletRequest request;
> +
> + public NamespacedRequestParameterMap(ServletRequest request) {
> + super(request);
> + this.request = request;
> + }
> +
> + @Override
> + public String get(Object key) {
> + String mapKey = key.toString();
> +
> + String value = request.getParameter(getNamingContainerId() + mapKey);
> +
> + if (value == null&& !mapKey.equals("param")) {
> + value = request.getParameter(mapKey);
> + }
> + return value;
> + }
> +
> + @Override
> + public boolean containsKey(Object key) {
> + String mapKey = key.toString();
> + boolean contains = (request.getParameter(getNamingContainerId()
> + + mapKey) != null);
> +
> + if (!contains&& !mapKey.equals("param")) {
> + contains = (request.getParameter(mapKey) != null);
> + }
> +
> + return contains;
> + }
> +}
> \ No newline at end of file
> --- a/test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/UserBean.java
> +++ b/test/agnostic/ajax-namespace/src/main/java/com/sun/faces/test/agnostic/ajax_namespace/UserBean.java
> @@ -2,13 +2,14 @@ package com.sun.faces.test.agnostic.ajax_namespace;
>
> import java.io.Serializable;
> import java.util.Date;
> -
> +import java.util.Map;
>
> import javax.faces.application.FacesMessage;
> import javax.faces.bean.ManagedBean;
> import javax.faces.bean.SessionScoped;
> import javax.faces.component.UIComponent;
> import javax.faces.context.FacesContext;
> +import javax.faces.event.ActionEvent;
> import javax.faces.validator.ValidatorException;
>
> @ManagedBean
> @@ -90,5 +91,15 @@ public class UserBean implements Serializable {
> FacesContext.getCurrentInstance().addMessage(null, doneMessage);
> return "done";
> }
> +
> + public void paramActionListener (ActionEvent actionEvent) {
> + Map<String, String> params =
> + FacesContext.getCurrentInstance().getExternalContext().
> + getRequestParameterMap();
> + String paramValue = params.get("param");
> + if (paramValue != null) {
> + this.lastName = this.lastName + " " + params.get("param");
> + }
> + }
> }
>
> --- a/test/agnostic/ajax-namespace/src/main/webapp/WEB-INF/faces-config.xml
> +++ b/test/agnostic/ajax-namespace/src/main/webapp/WEB-INF/faces-config.xml
> @@ -3,5 +3,6 @@
> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd">
> <factory>
> <application-factory>com.sun.faces.test.agnostic.ajax_namespace.ApplicationFactoryImpl</application-factory>
> +<external-context-factory>com.sun.faces.test.agnostic.ajax_namespace.ExternalContextFactoryImpl</external-context-factory>
> </factory>
> </faces-config>
> \ No newline at end of file
> --- a/test/agnostic/ajax-namespace/src/main/webapp/index.xhtml
> +++ b/test/agnostic/ajax-namespace/src/main/webapp/index.xhtml
> @@ -61,12 +61,33 @@
>
> <br />
>
> +<h:form id="ajaxFormParams" prependId="false">
> + <h:inputText id="ajaxInputParams" value="#{userBean.lastName}" />
> +<h:outputText id="ajaxOutputParams" value="#{userBean.lastName}" />
> +<h:commandButton id="ajaxSubmitParams" value="submit" actionListener="#{userBean.paramActionListener}">
> + <f:ajax render="@form" execute="@form"/>
> + <f:param name="param" value="value"/>
> +</h:commandButton>
> +</h:form>
> +
> +<br />
> +
> <h:form id="nonAjaxForm" prependId="false">
> <h:inputText id="nonAjaxInput" value="#{userBean.lastName}" />
> <h:outputText id="nonAjaxOutput" value="#{userBean.lastName}" />
> <h:commandButton id="nonAjaxSubmit" value="submit" />
> </h:form>
>
> +<br />
> +
> +<h:form id="nonAjaxFormParams" prependId="false">
> +<h:inputText id="nonAjaxInputParams" value="#{userBean.lastName}" />
> +<h:outputText id="nonAjaxOutputParams" value="#{userBean.lastName}" />
> +<h:commandButton id="nonAjaxSubmitParams" value="submit" actionListener="#{userBean.paramActionListener}">
> + <f:param name="param" value="value"/>
> +</h:commandButton>
> +</h:form>
> +
> </body>
>
> </f:view>
> --- a/test/agnostic/ajax-namespace/src/test/java/com/sun/faces/test/agnostic/ajax_namespace/Issue3031IT.java
> +++ b/test/agnostic/ajax-namespace/src/test/java/com/sun/faces/test/agnostic/ajax_namespace/Issue3031IT.java
> @@ -114,6 +114,26 @@ public class Issue3031IT {
> }
>
> @Test
> + public void testAjaxWithParams() throws Exception {
> + HtmlPage page = webClient.getPage(webUrl);
> +
> + HtmlElement input = (HtmlElement) page.getElementById("MyNamingContainerj_id1:ajaxInputParams");
> + assertTrue(null != input);
> + assertTrue(input instanceof HtmlTextInput);
> + HtmlTextInput textInput = (HtmlTextInput) input;
> + textInput.setText("MyText");
> +
> + HtmlSubmitInput button = (HtmlSubmitInput) page.getElementById("MyNamingContainerj_id1:ajaxSubmitParams");
> + page = button.click();
> + webClient.waitForBackgroundJavaScript(60000);
> +
> + HtmlElement output = (HtmlElement) page.getElementById("MyNamingContainerj_id1:ajaxOutputParams");
> + assertTrue(output.asText().contains("MyText value"));
> +
> +
> + }
> +
> + @Test
> public void testNonAjax() throws Exception {
> HtmlPage page = webClient.getPage(webUrl);
>
> @@ -132,4 +152,22 @@ public class Issue3031IT {
>
> }
>
> + @Test
> + public void testNonAjaxWithParams() throws Exception {
> + HtmlPage page = webClient.getPage(webUrl);
> +
> + HtmlElement input = (HtmlElement) page.getElementById("MyNamingContainerj_id1:nonAjaxInputParams");
> + assertTrue(null != input);
> + assertTrue(input instanceof HtmlTextInput);
> + HtmlTextInput textInput = (HtmlTextInput) input;
> + textInput.setText("MyNonAjaxText");
> +
> + HtmlSubmitInput button = (HtmlSubmitInput) page.getElementById("MyNamingContainerj_id1:nonAjaxSubmitParams");
> + page = button.click();
> +
> + HtmlElement output = (HtmlElement) page.getElementById("MyNamingContainerj_id1:nonAjaxOutputParams");
> + assertTrue(output.asText().contains("MyNonAjaxText value"));
> +
> +
> + }
> }
>
>
>
>