myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Werner Punz (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Comment Edited] (MYFACES-4229) Regression in Spec Issue 790: Cross form submit
Date Sun, 10 Jun 2018 20:09:00 GMT

    [ https://issues.apache.org/jira/browse/MYFACES-4229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16507488#comment-16507488
] 

Werner Punz edited comment on MYFACES-4229 at 6/10/18 8:08 PM:
---------------------------------------------------------------

Ok found the issue, the issue is closely related to MYFACES 4204

The spec states:

{color:#654982}_Locate and update the {{javax.faces.ViewState}} value for all JSF forms covered
in the +*{{render}} target list*+ whose ID starts with the same <VIEW_ROOT_CONTAINER_CLIENT_ID>
value._{color}

So the example also is wrong here. Clearly the only forms updated are the ones covered in
the render target list, because it covers both forms in the execute but not in the render
target list.
 <f:ajax execute="a :b" render=":b" /> 
 Which clearly says update only :b in this case.

So we have two issues. My code which does not take yet the viewroot prefix into consideration
(after the 4204 patch. I will fix it the next few days, and the example itself which basically,
it simply just updates the render targets atm... no biggie

this is just old behavior, all I have to add is the prefix check which will not make a difference)

Either way a quick fix for a permanent update all viewroots {color:#654982}*_myfaces.config.no_portlet_env
= true;_*{color}

Also another one could be simply to check all forms in the page for the correct prefix and
update all of them with a matching prefix. But this also would be not spec conform. I guess
we will closely follow the spec route here, no matter what.

In either way, the example clearly is wrong here by not adding both forms as render targets,
but I personally also think the spec itself is not ideal in this area and overly complicated
(it should always update all forms under one viewroot with the viewstate not only the render
targets)

To sum it up.
 * To fix the example add both forms as render targets this is spec conform
 * I have to do a small adjustment in my code
 * The spec itselfs might still be broken in this are, because  my personaly guess is you
safely always can update all forms within the same viewroot without any problem at all.

 


was (Author: werpu):
Ok found the issue, the issue is closely related to MYFACES 4204

The spec states:

{color:#654982}_Locate and update the {{javax.faces.ViewState}} value for all JSF forms covered
in the +*{{render}} target list*+ whose ID starts with the same <VIEW_ROOT_CONTAINER_CLIENT_ID>
value._{color}

So the example also is wrong here. Clearly the only forms updated are the once covered in
the render target list, because it covers both forms in the execute but not in the render
target list.
 <f:ajax execute="a :b" render=":b" /> 
 Which clearly says update only :b in this case.

So we have two issues. My code which does not take yet the viewroot prefix into consideration
(after the 4204 patch. I will fix it the next few days, and the example itself which basically,
it simply just updates the render targets atm... no biggie

this is just old behavior, all I have to add is the prefix check which will not make a difference)

Either way a quick fix for a permanent update all viewroots {color:#654982}*_myfaces.config.no_portlet_env
= true;_*{color}

Also another one could be simply to check all forms in the page for the correct prefix and
update all of them with a matching prefix. But this also would be not spec conform. I guess
we will closely follow the spec route here, no matter what.

In either way, the example clearly is wrong here by not adding both forms as render targets,
but I personally also think the spec itself is not ideal in this area and overly complicated
(it should always update all forms under one viewroot with the viewstate not only the render
targets)

To sum it up.
 * To fix the example add both forms as render targets this is spec conform
 * I have to do a small adjustment in my code
 * The spec itselfs might still be broken in this are, because  my personaly guess is you
safely always can update all forms within the same viewroot without any problem at all.

 

> Regression in Spec Issue 790: Cross form submit
> -----------------------------------------------
>
>                 Key: MYFACES-4229
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4229
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-372
>    Affects Versions: 2.3.1
>            Reporter: Eduardo Breijo
>            Assignee: Werner Punz
>            Priority: Major
>             Fix For: 2.3.2
>
>         Attachments: JSF23Spec790.war
>
>
> After releasing MyFaces 2.3.1, I noticed a regression in cross form submit from Spec
Issue 790: [https://github.com/javaee/javaserverfaces-spec/issues/790]
> HTML sample code:
> {code:java}
> <h:form id="a"> 
> <h:outputText value="This is 'form a' " /> 
> <h:outputLabel for="input1" value="Enter a new value for input1: " /> <h:inputText
id="input1" value="#{simpleBean.input}" /> 
> <h:commandButton id="submitButton1" value="Click here to execute 'form a' and 'form
b' but re-render 'form b'"> 
> <f:ajax execute="a :b" render=":b" /> 
> </h:commandButton> 
> </h:form> 
> <h:form id="b"> 
> <h:outputText value="This is 'form b' " /> 
> <h:outputLabel for="input2" value="Enter a new value for input2: " /> <h:inputText
id="input2" value="#{simpleBean.input}" /> 
> <h:commandLink id="commandLink1" value="Click here to execute 'form a' and 'form b' 
but re-render 'form a'"> 
> <f:ajax execute="b :a" render=":a" /> 
> </h:commandLink> 
> </h:form>
> {code}
>  
> The issue is that on MyFaces 2.3.1 the hidden input javax.faces.ViewState is being removed
from form "b" after we submit form "a" and viceversa. As a result, cross form submit is
not working as expected, you either have to refresh the page before executing submit on the
second form or you have to execute submit twice so the update is reflected in the other form.
> Rendered page on MyFaces 2.3.0
> {code:java}
> <form id="a" name="a" method="post" action="/JSF23Spec790/test1.xhtml" enctype="application/x-www-form-urlencoded">
This is 'form a' 
> <label for="a:input1"> Enter a new value for input1: </label> 
> <input id="a:input1" name="a:input1" type="text" value="test"/> 
> <input id="a:submitButton1" name="a:submitButton1" type="submit" value="Click here
to execute 'form a' and 'form b' but re-render 'form b'" onclick="jsf.util.chain(this, event,'jsf.ajax.request(this,event,{execute:\'a
b \',render:\'b \',\'javax.faces.behavior.event\':\'action\'})'); return false;"/> 
> <input type="hidden" name="a_SUBMIT" value="1"/> 
> <input type="hidden" name="javax.faces.ViewState" id="j_id__v_0:javax.faces.ViewState:1"
value="RjhDMEFGQUMwNDI4NTUwRDAwMDAwMDAx" autocomplete="off"/> 
> </form> 
> <form id="b" name="b" method="post" action="/JSF23Spec790/test1.xhtml" enctype="application/x-www-form-urlencoded">
This is 'form b' 
> <label for="b:input2"> Enter a new value for input2: </label> 
> <input id="b:input2" name="b:input2" type="text" value="test"/> 
> <a href="#" onclick="jsf.util.chain(this, event,'jsf.ajax.request(this,event,{execute:\'b
a \',render:\'a \',\'javax.faces.behavior.event\':\'action\'})'); return false;" id="b:commandLink1"
name="b:commandLink1"> Click here to execute 'form a' and 'form b' but re-render 'form
a' </a> 
> <input type="hidden" name="b_SUBMIT" value="1"/> 
> <input type="hidden" id="javax.faces.ViewState:0" name="javax.faces.ViewState" value="RjhDMEFGQUMwNDI4NTUwRDAwMDAwMDAx"/>

> </form>
> {code}
>  
> Rendered page on MyFaces 2.3.1
> {code:java}
> <form id="a" name="a" method="post" action="/JSF23Spec790/test1.xhtml" enctype="application/x-www-form-urlencoded">
This is 'form a' 
> <label for="a:input1"> Enter a new value for input1: </label> 
> <input id="a:input1" name="a:input1" type="text" value="test"/> 
> <input id="a:submitButton1" name="a:submitButton1" type="submit" value="Click here
to execute 'form a' and 'form b' but re-render 'form b'" onclick="jsf.util.chain(this, event,'jsf.ajax.request(this,event,{execute:\'a
b \',render:\'b \',\'javax.faces.behavior.event\':\'action\'})'); return false;"/> 
> <input type="hidden" name="a_SUBMIT" value="1"/> 
> <input type="hidden" name="javax.faces.ViewState" id="j_id__v_0:javax.faces.ViewState:1"
value="RjY3MjAyMTY3N0U2ODE3RDAwMDAwMDAx" autocomplete="off"/> 
> </form> 
> <form id="b" name="b" method="post" action="/JSF23Spec790/test1.xhtml" enctype="application/x-www-form-urlencoded">
This is 'form b' 
> <label for="b:input2"> Enter a new value for input2: </label> 
> <input id="b:input2" name="b:input2" type="text" value="test"/> 
> <a href="#" onclick="jsf.util.chain(this, event,'jsf.ajax.request(this,event,{execute:\'b
a \',render:\'a \',\'javax.faces.behavior.event\':\'action\'})'); return false;" id="b:commandLink1"
name="b:commandLink1"> Click here to execute 'form a' and 'form b' but re-render 'form
a' </a> 
> <input type="hidden" name="b_SUBMIT" value="1"/> 
> </form>
> {code}
>  
> I have provided a sample app that shows the issue when MyFaces 2.3.1 is used.
>  # Just deploy the app on Tomcat and drive a request to: [http://localhost:8080/JSF23Spec790/test1.xhtml]
>  # Enter a text in input1 and click submit button next to the input. Check the rendered
page.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message