dev@javaserverfaces.java.net

Re: https://java.net/jira/browse/JAVASERVERFACES-4124

From: zhijun Ren <ren.zhijun_at_oracle.com>
Date: Wed, 13 Apr 2016 16:03:36 +0800

Hi Ruolin,

I am ok with your change now, please go ahead with the commit. Please
key an eye on the Hudson jobs of 2.3 and ensure not break them.

BR,
Zhijun


On 4/13/16, 15:55, Ruolin Li wrote:
> Zhijun,
>
> The submission to Mojarra master branch is now ready.
> Below is the diff, please help review it.
>
> Thanks and best regards
> Ruolin
>
> ==============
> ruolli_at_ruolli-Ubuntu: ~/GIT/mojarra~git $ git diff HEAD^ HEAD
> diff --git
> a/jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.javab/jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java
> index d596dac..fcadda7 100644
> ---
> a/jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java
> +++
> b/jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java
> @@ -278,7 +278,7 @@ public final class ComponentSupport {
> * @return the UI component
> */
> public static UIComponent findChildByTagId(FacesContext context,
> UIComponent parent, String id) {
> - if (isBuildingNewComponentTree(context)) {
> + if ( !context.isPostback() ) {
> return null;
> }
> UIComponent c = null;
> diff --git
> a/test/javaee6web/facelets/src/main/java/com/sun/faces/test/javaee6web/facelets/DuplicateController.javab/test/javaee6web/facelets/src/main/java/com/sun/faces/test/javaee6web/fa
> new file mode 100644
> index 0000000..5876717
> --- /dev/null
> +++
> b/test/javaee6web/facelets/src/main/java/com/sun/faces/test/javaee6web/facelets/DuplicateController.java
> @@ -0,0 +1,87 @@
> +/*
> + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
> + *
> + * Copyright (c) 1997-2015 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.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.javaee6web.facelets;
> +
> +import java.util.ArrayList;
> +import java.util.List;
> +import javax.faces.bean.ManagedBean;
> +import javax.faces.bean.ViewScoped;
> +import javax.faces.component.html.HtmlDataTable;
> +
> +_at_ManagedBean(
> + name = "duplicateController"
> +)
> +_at_ViewScoped
> +public class DuplicateController {
> + private static final long serialVersionUID = 1L;
> + private List<String> itemsList = new ArrayList();
> + private HtmlDataTable dataTable;
> +
> + public DuplicateController() {
> + }
> +
> + public void createNewRow() {
> + this.incRows();
> + String s = "new:" + (new Object()).hashCode();
> + this.itemsList.add(0, s);
> + }
> +
> + private void incRows() {
> + int rows = this.dataTable.getRows();
> + this.dataTable.setRows(rows + 1);
> + }
> +
> + public HtmlDataTable getDataTable() {
> + return this.dataTable;
> + }
> +
> + public void setDataTable(HtmlDataTable dataTable) {
> + this.dataTable = dataTable;
> + }
> +
> + public List<String> getItemsList() {
> + return this.itemsList;
> + }
> +
> + public void setItemsList(List<String> itemsList) {
> + this.itemsList = itemsList;
> + }
> +}
> +
> diff --git a/test/javaee6web/facelets/src/main/webapp/issue4124.xhtml
> b/test/javaee6web/facelets/src/main/webapp/issue4124.xhtml
> new file mode 100644
> index 0000000..48f3512
> --- /dev/null
> +++ b/test/javaee6web/facelets/src/main/webapp/issue4124.xhtml
> @@ -0,0 +1,73 @@
> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> +
> +<!--
> +
> + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
> +
> + Copyright (c) 1997-2015 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.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.
> +
> +-->
> +
> +
> +<html xmlns="http://www.w3.org/1999/xhtml"
> + xmlns:ui="http://java.sun.com/jsf/facelets"
> + xmlns:h="http://java.sun.com/jsf/html"
> + xmlns:f="http://java.sun.com/jsf/core">
> +
> +<f:view>
> + <h:body>
> + <h:form prependId="false" id="hForm">
> + <h:dataTable prependId="false" id="duplicatesTable"
> + binding="#{duplicateController.dataTable}"
> + value="#{duplicateController.itemsList}"
> + var="s" rowKey="#{s}">
> +
> + <h:column prependId="false" id="pColumn">
> + <f:facet name="header">
> + <h:commandButton prependId="false" id="pSplitButton"
> +
> actionListener="#{duplicateController.createNewRow}"
> + update="duplicatesTable" value="Add Row">
> + </h:commandButton>
> + </f:facet>
> + <h:outputText id="hOutputText" value="#{s}" />
> + </h:column>
> + </h:dataTable>
> + </h:form>
> + </h:body>
> +</f:view>
> +</html>
> diff --git
> a/test/javaee6web/facelets/src/test/java/com/sun/faces/test/javaee6web/facelets/Issue4124IT.javab/test/javaee6web/facelets/src/test/java/com/sun/faces/test/javaee6web/facelets/I
> new file mode 100644
> index 0000000..33314cd
> --- /dev/null
> +++
> b/test/javaee6web/facelets/src/test/java/com/sun/faces/test/javaee6web/facelets/Issue4124IT.java
> @@ -0,0 +1,100 @@
> +/*
> + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
> + *
> + * Copyright (c) 1997-2016 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.java.net/public/CDDLGPL_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.javaee6web.facelets;
> +
> +import com.gargoylesoftware.htmlunit.WebClient;
> +import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
> +import com.gargoylesoftware.htmlunit.html.HtmlPage;
> +import com.gargoylesoftware.htmlunit.html.DomElement;
> +import com.gargoylesoftware.htmlunit.html.DomNode;
> +import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
> +import com.gargoylesoftware.htmlunit.html.HtmlForm;
> +import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
> +import com.sun.faces.test.htmlunit.IgnoringIncorrectnessListener;
> +import org.junit.After;
> +import org.junit.Before;
> +import org.junit.Test;
> +import java.util.Iterator;
> +import static org.junit.Assert.*;
> +
> +public class Issue4124IT {
> +
> + private String webUrl;
> + private WebClient webClient;
> +
> + @Before
> + public void setUp() {
> + webUrl = System.getProperty("integration.url");
> + webClient = new WebClient();
> + webClient.getOptions().setJavaScriptEnabled(true);
> + webClient.setJavaScriptTimeout(120000);
> + }
> +
> + @Test
> + public void testIssue4124() throws Exception {
> +
> + HtmlPage page = webClient.getPage(webUrl +
> "faces/issue4124.xhtml");
> + DomNode dn =
> page.getHtmlElementById("duplicatesTable").getLastChild();
> + int count = dn.getChildNodes().size();
> + assertTrue(count == 1);
> +
> + page =
> page.getHtmlElementById("duplicatesTable:pSplitButton").click();
> + dn = page.getHtmlElementById("duplicatesTable").getLastChild();
> + count = dn.getChildNodes().size();
> + assertTrue(count == 1);
> +
> + page =
> page.getHtmlElementById("duplicatesTable:pSplitButton").click();
> + dn = page.getHtmlElementById("duplicatesTable").getLastChild();
> + count = dn.getChildNodes().size();
> + assertTrue(count == 2);
> +
> + page =
> page.getHtmlElementById("duplicatesTable:pSplitButton").click();
> + dn = page.getHtmlElementById("duplicatesTable").getLastChild();
> + count = dn.getChildNodes().size();
> + assertTrue(count == 3);
> +
> + }
> +
> + @After
> + public void tearDown() {
> + webClient.closeAllWindows();
> + }
> +
> +}
> ruolli_at_ruolli-Ubuntu: ~/GIT/mojarra~git $
>
> ==============
> --
> Ruolin Li (ruolin.li_at_oracle.com)
> Oracle Weblogic Server WebApp Container Team
> 86 10 61065387