[ https://issues.apache.org/jira/browse/MYFACES-4605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17735808#comment-17735808 ]
Joe Crichton commented on MYFACES-4605: --------------------------------------- Here is a simple two form two button case: {noformat} <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:jsf="http://xmlns.jcp.org/jsf" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:o="http://omnifaces.org/ui" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"> <h:head> <meta http-equiv="Cache-Control" content="no-cache" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="Thu, 01 Dec 1994 16:00:00 GMT" /> <meta name="decorator" content="none"/> <title>Carbon Title</title> </h:head> <h:body> <h:form id="f1"> <h:commandButton value="pushme form 1"> <f:ajax event="click" render=":div2"/> </h:commandButton> </h:form> <div jsf:id="div2"> <h:form id="f2"> <h:commandButton value="pushme form 2"> <f:ajax event="click" render=":f1/> </h:commandButton> </h:form> </div> </h:body> </html> {noformat} This is what I see in the browser inspect panel ... both forms have the viewstate present: {noformat} <html xmlns="http://www.w3.org/1999/xhtml" xmlns:carbon="http://java.sun.com/jsf/composite/carbon"> <head id="j_id_2"> <link type="text/css" rel="stylesheet" href="/technologyconnect/jakarta.faces.resource/theme.css.xhtml?ln=primefaces-saga&v=12.0.0"> <link type="text/css" rel="stylesheet" href="/technologyconnect/jakarta.faces.resource/primeicons/primeicons.css.xhtml?ln=primefaces&v=12.0.0"> <script type="text/javascript" src="/technologyconnect/jakarta.faces.resource/jsf.js.xhtml?ln=jakarta.faces"></script> <script type="text/javascript">if(window.PrimeFaces){PrimeFaces.settings.locale='en_US';PrimeFaces.settings.viewId='/joetest.xhtml';PrimeFaces.settings.contextPath='/technologyconnect';PrimeFaces.settings.cookiesSecure=false;}</script> <meta http-equiv="Cache-Control" content="no-cache"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Expires" content="Thu, 01 Dec 1994 16:00:00 GMT"> <title>Carbon Title</title></head> <body> <script type="text/javascript"> myfaces.config._autoeval = true; </script> <form id="f1" name="f1" method="post" action="/technologyconnect/joetest.xhtml" enctype="application/x-www-form-urlencoded"> <input id="f1:j_id_6" name="f1:j_id_6" type="submit" value="pushme form 1" onclick="jsf.util.chain(this, event,'jsf.ajax.request(this,event,{render:\'div2 \',\'jakarta.faces.behavior.event\':\'click\'})'); return false;"> <input type="hidden" name="f1_SUBMIT" value="1"> <input type="hidden" name="jakarta.faces.ViewState" id="j_id__v_0:jakarta.faces.ViewState:1" value="OGQ4ZTBlNzJhYWI2NDQ0NTAwMDAwMDA2" autocomplete="off"> </form> <div id="div2"> <form id="f2" name="f2" method="post" action="/technologyconnect/joetest.xhtml" enctype="application/x-www-form-urlencoded"> <input id="f2:j_id_9" name="f2:j_id_9" type="submit" value="pushme form 1" onclick="jsf.util.chain(this, event,'jsf.ajax.request(this,event,{render:\'div2 \',\'jakarta.faces.behavior.event\':\'click\'})'); return false;"> <input type="hidden" name="f2_SUBMIT" value="1"> <input type="hidden" name="jakarta.faces.ViewState" id="j_id__v_0:jakarta.faces.ViewState:2" value="OGQ4ZTBlNzJhYWI2NDQ0NTAwMDAwMDA2" autocomplete="off"> </form> </div> </body> </html>{noformat} When I press the first button, this is what I see come back from the post, so it actually updates j_id__v_0:jakarta.faces.ViewState:1, and does not include the viewstate in the 2nd form being rendered {noformat} <?xml version="1.0" encoding="UTF-8"?><partial-response id="j_id__v_0"><changes><update id="div2"><![CDATA[<div id="div2"><form id="f2" name="f2" method="post" action="/technologyconnect/joetest.xhtml" enctype="application/x-www-form-urlencoded"><input id="f2:j_id_9" name="f2:j_id_9" type="submit" value="pushme form 1" onclick="jsf.util.chain(this, event,'jsf.ajax.request(this,event,{render:\'div2 \',\'jakarta.faces.behavior.event\':\'click\'})'); return false;" /><input type="hidden" name="f2_SUBMIT" value="1" /></form></div>]]></update><update id="j_id__v_0:jakarta.faces.ViewState:1"><![CDATA[OGQ4ZTBlNzJhYWI2NDQ0NTAwMDAwMDA2]]></update></changes></partial-response>{noformat} However, after the jsf update completes, the 2nd form DOES have a viewstate value listed with id of j_id__v_0:jakarta.faces.ViewState:0 (different than anything seen thus far). {noformat} <div id="div2"> <form id="f2" name="f2" method="post" action="/technologyconnect/joetest.xhtml" enctype="application/x-www-form-urlencoded"> <input id="f2:j_id_9" name="f2:j_id_9" type="submit" value="pushme form 2" onclick="jsf.util.chain(this, event,'jsf.ajax.request(this,event,{render:\'f1 \',\'jakarta.faces.behavior.event\':\'click\'})'); return false;"> <input type="hidden" name="f2_SUBMIT" value="1"> <input type="hidden" id="j_id__v_0:jakarta.faces.ViewState:0" name="jakarta.faces.ViewState" value="YjFiOGU5ZjFjNmMzNjJkMjAwMDAwMDEx"> </form> </div>{noformat} So maybe a wild goose chase (sorry). The original issue was an error case I had caused during the conversion to Jakarta JSF 3.0 dealing with Omnifaces. When I fixed my name space issue, the code was working, using the Balusc workaround for 2nd form viewstate fixup. > Cross form rending via ajax, form is missing ViewState > ------------------------------------------------------ > > Key: MYFACES-4605 > URL: https://issues.apache.org/jira/browse/MYFACES-4605 > Project: MyFaces Core > Issue Type: Bug > Affects Versions: 3.0.1, 2.3.10 > Reporter: Joe Crichton > Assignee: Werner Punz > Priority: Major > Fix For: 2.3.11, 3.0.3 > > Attachments: image-2023-06-20-21-22-50-593.png > > > Seems this is an old issue, which was presumably fixed for MyFaces in 2.2 as > discussed here > [https://balusc.omnifaces.org/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichContainsAnotherForm|https://balusc.omnifaces.org/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichContainsAnotherForm),] > and [https://github.com/jakartaee/faces/issues/790] > Using openliberty with jsf-3.0 feature still has this occurring. Using the > workaround outlined by the first link fixes the issue. I believe the same is > true for the jsf-2.3 feature as well. -- This message was sent by Atlassian Jira (v8.20.10#820010)