From dev-return-70452-archive-asf-public=cust-asf.ponee.io@myfaces.apache.org Wed Dec 5 22:29:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 0328D18062B for ; Wed, 5 Dec 2018 22:29:04 +0100 (CET) Received: (qmail 14047 invoked by uid 500); 5 Dec 2018 21:29:04 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 14027 invoked by uid 99); 5 Dec 2018 21:29:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Dec 2018 21:29:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id EDAEDC0413 for ; Wed, 5 Dec 2018 21:29:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.581 X-Spam-Level: X-Spam-Status: No, score=-0.581 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_FAIL=0.919] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id tcFTc8WLHIgi for ; Wed, 5 Dec 2018 21:29:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 38F825F18A for ; Wed, 5 Dec 2018 21:29:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 99894E0E5D for ; Wed, 5 Dec 2018 21:29:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 336D327774 for ; Wed, 5 Dec 2018 21:29:00 +0000 (UTC) Date: Wed, 5 Dec 2018 21:29:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@myfaces.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MYFACES-4267) transient attribute is not inherited from template to final page. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MYFACES-4267?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D16= 710651#comment-16710651 ]=20 ASF GitHub Bot commented on MYFACES-4267: ----------------------------------------- wtlucy closed pull request #28: MYFACES-4267 transient template inheritance= issue URL: https://github.com/apache/myfaces/pull/28 =20 =20 =20 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletVie= wDeclarationLanguage.java b/impl/src/main/java/org/apache/myfaces/view/face= lets/FaceletViewDeclarationLanguage.java index cd417632c..20113ff27 100644 --- a/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclar= ationLanguage.java +++ b/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclar= ationLanguage.java @@ -2085,24 +2085,22 @@ public UIViewRoot restoreView(FacesContext context,= String viewId) { view =3D viewHandler.createView(context, viewId); } - // If the view is not transient, then something is wrong. = Throw an exception. - if (!view.isTransient()) + context.setViewRoot (view);=20 + boolean oldContextEventState =3D context.isProcessingEvent= s(); + try=20 { - throw new FacesException ("unable to create view \"" += viewId + '"'); - }=20 - else - { - context.setViewRoot (view);=20 - boolean oldContextEventState =3D context.isProcessingE= vents(); - try=20 + context.setProcessingEvents (true); + vdl.buildView (context, view); + + // If the view is not transient, then something is wro= ng. Throw an exception. + if (!view.isTransient()) { - context.setProcessingEvents (true); - vdl.buildView (context, view); + throw new FacesException ("unable to create view \= "" + viewId + "\""); } - finally - { - context.setProcessingEvents(oldContextEventState); - }=20 + } + finally + { + context.setProcessingEvents(oldContextEventState); } } catch (Throwable e) diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/stateless/= StatelessTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/st= ateless/StatelessTest.java index d4f070276..fbb7e71b6 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/stateless/Statele= ssTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/stateless/Statele= ssTest.java @@ -20,6 +20,8 @@ =20 import javax.faces.application.StateManager; import javax.faces.component.UIComponent; +import javax.faces.render.ResponseStateManager; + import org.apache.myfaces.config.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; import org.junit.Assert; @@ -42,87 +44,47 @@ protected void setUpWebConfigParams() throws Exception { super.setUpWebConfigParams(); servletContext.addInitParameter("org.apache.myfaces.annotation.SCA= N_PACKAGES","org.apache.myfaces.view.facelets.stateless"); - servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_P= ARAM_NAME, StateManager.STATE_SAVING_METHOD_CLIENT); + servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_P= ARAM_NAME, StateManager.STATE_SAVING_METHOD_SERVER); servletContext.addInitParameter("javax.faces.PARTIAL_STATE_SAVING"= , "true"); servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_REFRESH_T= RANSIENT_BUILD_ON_PSS, "auto"); servletContext.addInitParameter("org.apache.myfaces.STRICT_JSF_2_R= EFRESH_TARGET_AJAX", "true"); } =20 + /** + * Verify that a view with a template that has transient set can be re= stored + *=20 + * @throws Exception + */ @Test - public void postWithoutPrependFormId() throws Exception + public void restoreStatelessTemplateView() throws Exception { startViewRequest("/stateless.xhtml"); processLifecycleExecuteAndRender(); - =20 - Assert.assertTrue(facesContext.getViewRoot().isTransient()); - =20 - UIComponent form =3D facesContext.getViewRoot().findComponent("for= m1"); - UIComponent formButton =3D facesContext.getViewRoot().findComponen= t("form1:smt"); - =20 - client.submit(formButton); - =20 - processLifecycleExecuteAndRender(); - String text =3D getRenderedContent(facesContext); =20 - endRequest(); - } - =20 - @Test - public void postAjaxWithoutPrependFormId() throws Exception - { - startViewRequest("/stateless.xhtml"); - processLifecycleExecuteAndRender(); - =20 Assert.assertTrue(facesContext.getViewRoot().isTransient()); - =20 - UIComponent form =3D facesContext.getViewRoot().findComponent("for= m1"); - UIComponent formButton =3D facesContext.getViewRoot().findComponen= t("form1:smtAjax"); - =20 - client.ajax(formButton, "action", formButton.getClientId(facesCont= ext), form.getClientId(facesContext), true); - =20 - processLifecycleExecuteAndRender(); - String text =3D getRenderedContent(facesContext); =20 - endRequest(); - } - =20 - @Test - public void postWithPrependFormId() throws Exception - { - startViewRequest("/stateless.xhtml"); - processLifecycleExecuteAndRender(); - =20 - Assert.assertTrue(facesContext.getViewRoot().isTransient()); - =20 - UIComponent form =3D facesContext.getViewRoot().findComponent("for= m2"); - UIComponent formButton =3D facesContext.getViewRoot().findComponen= t("form2:smt"); - =20 + // set the view state param so this context is treated as a postba= ck + client.getParameters().put(ResponseStateManager.VIEW_STATE_PARAM, = "stateless"); + UIComponent formButton =3D facesContext.getViewRoot().findComponen= t("smt"); client.submit(formButton); - =20 - processLifecycleExecuteAndRender(); - String text =3D getRenderedContent(facesContext); =20 - endRequest(); - } + try { + // this will cause an exception without the fix in MYFACES-426= 7 + restoreView(); + } catch (Exception e) { + Assert.fail("caught an exception trying to restore a stateless= view: " + e.getMessage()); + endRequest(); + return; + } =20 - @Test - public void postAjaxWithPrependFormId() throws Exception - { - startViewRequest("/stateless.xhtml"); - processLifecycleExecuteAndRender(); - =20 - Assert.assertTrue(facesContext.getViewRoot().isTransient()); - =20 - UIComponent form =3D facesContext.getViewRoot().findComponent("for= m2"); - UIComponent formButton =3D facesContext.getViewRoot().findComponen= t("form2:smtAjax"); - =20 - client.ajax(formButton, "action", formButton.getClientId(facesCont= ext), form.getClientId(facesContext), true); - =20 - processLifecycleExecuteAndRender(); + Assert.assertNotNull(facesContext.getViewRoot()); + + // render the response and make sure the view contains the expecte= d text + renderResponse(); String text =3D getRenderedContent(facesContext); =20 + Assert.assertTrue(text.contains("success")); + endRequest(); } - =20 - =20 } diff --git a/impl/src/test/resources/org/apache/myfaces/view/facelets/state= less/stateless.xhtml b/impl/src/test/resources/org/apache/myfaces/view/face= lets/stateless/stateless.xhtml index 6388315ad..54e301b88 100644 --- a/impl/src/test/resources/org/apache/myfaces/view/facelets/stateless/st= ateless.xhtml +++ b/impl/src/test/resources/org/apache/myfaces/view/facelets/stateless/st= ateless.xhtml @@ -6,7 +6,7 @@ template=3D"template.xhtml"> =20 - + success! =20 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. =20 For queries about this service, please contact Infrastructure at: users@infra.apache.org > transient attribute is not inherited from template to final page. > ----------------------------------------------------------------- > > Key: MYFACES-4267 > URL: https://issues.apache.org/jira/browse/MYFACES-4267 > Project: MyFaces Core > Issue Type: Bug > Components: Extension Feature > Affects Versions: 2.3.2 > Reporter: Antgar > Priority: Major > Fix For: 2.3.3, 3.0.0-SNAPSHOT > > > After upgrading from Myfaces 2.2 to 2.3, templated transient views stop t= o work, raising "unable to create views" exceptions. > f:view transient attribute defined in a template seems not to be inherite= d by the final page correctly. With myfaces 2.2 it worked correctly, but in= 2.3, there is a new check=C2=A0 > {code:java} > if (!view.isTransient()) ... > {code} > on FaceletViewDeclarationLanguage line 2128. On page restoring, transient= appears as false. > A workaround is to set transient=3D"true" on the final page too. Other op= tion is to use a block=C2=A0 > {code:java} > > {code} > on the final page (f:metadata doc says it shouldn't be used in templates)= . -- This message was sent by Atlassian JIRA (v7.6.3#76005)