2 Replies Latest reply on Jun 6, 2014 5:21 AM by nielsbechnielsen

    Losing viewstate in only one form (or re-rendering of a form)

    nielsbechnielsen

      I have a problem of loosing the viewstate on ajax update.

      rich-faces 4.3.4, on mojarra 2.2.5, on tomcat 7 with java7

       

      It is likely related to the generic problem (https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-790), but I can't really put the finger on the spot. I have narrowed it down to a very explicit scenario, that just doesn't work for me.

       

      The table below opens a popup on each element, still within the form and shows the data item. Works fine. The demo has a fix model of 10 every time.

      (Originally the popup might do some modification on a bean which the table depended on, so a render of the entire form was necessary, but I have simplified it here).

      When I re-render the form using the a4j:commandbutton with execute="@this" and render="@form", I can no longer get my id's passed to the dialog.

       

      I notice on the a4j log that all requests seems to send a viewstate update back, which subsequently fails with

      richfaces.queue: ajax submit error: During update: javax.faces.ViewState not found.


      I noticed that the updated form was explicitly without the hidden viewstate parameter, and so it never gets posted back.

      I did notice the FINE: Postback: restored view for /test.jspx on all requests including the re-render, and subsequent loss of it and getting: FINE: New request: creating a view for /test.jspx.However, given that it rendered the entire model anew, wouldn't it have worked anyway?


      So, basically. After re-rendering the form, I can no longer get the a4j:param working..


      Does anybody have any clues? I have tried many, many things by now, without much help.



      <h:body>

        <h:form id="form1">

       

          <rich:dataTable value="#{demoController.model}" var="m">

            <rich:column>#{m.id}</rich:column>

            <rich:column>

              <a4j:commandLink execute="@this" render="demopopup" title="Go"

                oncomplete="#{rich:component('demopopup')}.show()">

                <a4j:param value="#{m.id}" assignTo="#{demoCommand.demoid}" />

                <h:outputText value="Open" />

              </a4j:commandLink>

            </rich:column>

       

          </rich:dataTable>

          <a4j:commandButton value="Re-render" execute="@this" render="@form"/>

       

       

          <rich:popupPanel id="demopopup" domElementAttachment="form" autosized="true"

            onmaskclick="#{rich:component('demopopup')}.hide()">

            <h:panelGrid columns="2">

              <h:outputLabel value="id" styleClass="bold" for="vid"/>

              <h:outputText id="vid" value="#{demoCommand.editedDemo.id}" />

            </h:panelGrid>

          </rich:popupPanel>

        </h:form>

       

        <a4j:log level="debug" />

       

      </h:body>

       

       

      Regards

        • 1. Re: Losing viewstate in only one form (or re-rendering of a form)
          michpetrov

          Hi,

          have you tried it with an older version of Mojarra (RF 4.3.4 comes with 2.1.19). I think 2.2.x handles viewState a bit differently and that's likely what is causing. Also, if you can, please provide a whole web project; it would be much easier to check what's wrong.

          1 of 1 people found this helpful
          • 2. Re: Re: Losing viewstate in only one form (or re-rendering of a form)
            nielsbechnielsen

            I have attached a separate project with this explicit demonstration only.. Feel free to try out and elaborate on.

             

            I will certainly look into the version issue, however, it failed to parse the facelet correctly when I tried initially, but I'll give it a considerate effort.

            (Update, I had forgotten about the change in namespace between JSF 2.1 and 2.2. Seems to work with mojarra 2.1.19 and richfaces 4.3.6.Final)

             

            I annoys me, though, that almost all of my other views work with this skew combination.. I'm sure we went to JSF 2.2. because of something else, so...

             

            Does anyone know when I richfaces version compatible with JSF 2.2 will be out?