0 Replies Latest reply on Dec 1, 2008 9:32 PM by Israel Fonseca

    Ajax, Richfaces, Conversation and Refresh

    Israel Fonseca Apprentice
      Well, i think that i do not fully understand the seam conversations, so could someone give me some answers?

      I made this sample application to show my problems.


      @Name("person")
      @Scope(ScopeType.CONVERSATION)
      public class Person {
           
           private String name;

           public String getName() {
                return name;
           }

           public void setName(String name) {
                this.name = name;
           }
           
           public String random(){
                return Math.random()+"";
           }

      }


      ----------------- my test.xhtml --------------------
           <ui:define name="content">
                
                <a4j:form id="form">
                     Value:<h:outputText value="#{person.name}"/>
                     Random:<h:outputText value="#{person.random()}"/>
                     <br/><h:inputText value="#{person.name}"/>
                     <a4j:commandButton value="Save" reRender="form"/>
                </a4j:form>
                
                <a4j:form id="otherForm">
                     <a4j:commandButton value="End conversation!" action="#{conversation.end()}" reRender="form"/>
                </a4j:form>

                <a4j:form id="moreOneForm">
                     <a4j:commandButton value="Just rerender!" reRender="form"/>
                </a4j:form>

           </ui:define>

      ---------------my page.xml-----------
      <page view-id="/public/test.xhtml">
               <begin-conversation join="true"/>
      </page>


      Well, it's pretty simple, the random stuff, is just o see the rerender working. Well let's see the problem.

      0 - I enter the page, and my conversation is promoted to a long-running-conversation. //ok
      1 - I put a name (James) and press save. //Now i suppose that the person component is stored in the conversation context, and should be there until it founds an @End or something like that.
      2 -Ok, the James appear in the output text, and i click the "Just ReRender" button. // All right, the output is still showing James, this means that the person is still in the context, as i expected.

      Now.. the problems. If i press the refresh button in my browser, the James names disappear.. But why? I thought that the context would be destroyed ONLY when I invoked something with an @End, or the conversation time expired.

      And.. if i pressed the "End Conversation" button.. well the conversation is still there, and the James name too. Shouldn't it be destroyed? What am i doing wrong?

      Thks in advance.

      Israel