1 Reply Latest reply on Apr 13, 2011 6:28 AM by Andrew Wheeler

    Conversation propagation without page viewParam

    Andrew Wheeler Newbie

      If a page GET does not include a viewParm and the page is backed by a conversation bean that is promoted to long running then the conversation context is lost on any page action.


      Take the following code snippet:


      <f:metadata>
           <f:viewParam name="age" value="#{testBean.age}"/>
      </f:metadata>
      <ui:define name="title">Testing</ui:define>
      <ui:define name="body">
           <h1>Testing</h1>
           <h:form>
              <h:panelGroup styleClass="property" layout="block">
                  <h:outputLabel value="Age:" for="age"/>
                 <h:inputText id="age" size="2" maxlength="2" value="#{testBean.age}" label="Age"/>
               </h:panelGroup>
          
           <h:commandButton id="test" value="Test" action="#{testBean.test}"/>
           </h:form>
      </ui:define> 



      The backing bean promotes the conversation:


           @PostConstruct
           protected void postConstruct() {
                conversation.begin();
                log.debug("Post construct. Conversation is {}", conversation.getId());
           }





      If the page is invoked simply as test.jsf then when executing the test action a new conversation is started. If however the page is invoked as test.jsf?age=99 then the conversation context is retained.


      The second issue is that if the conversation is promoted to long running in the postConstruct method and the page is a GET request with a page param then if the page is refreshed before the page action a new conversation is begun. This could occur if the user hits browser refresh or clicks on the URL and hits enter. Could the ConversationAwareViewHandler perhaps store the conversation id in the page state?


      And one more thing, why does the action propagate the conversation id but not the original request parameters? After pressing Test the page URL is test.jsf?cid=1. This is not as bookmarkable as test.jsf?age=99. In fact adding conversation id to the request parameters makes it non-bookmarkable.


      I'm running under JBoss AS6, Mojarra 2.1.