2 Replies Latest reply on Jun 20, 2006 4:19 PM by rlhr

    About propagating a value in a conversation

      Hello,

      I have a conversation started through a page action ("Push"-style MVC).

      In pages.xml, I have:

      <page view-id="/check.xhtml" action="#{check.perform}" />
      

      The bean is define as followed:

      @Stateless
      @Name("check")
      public class CheckAction implements Check {
      
       @Out(scope=ScopeType.SESSION, required=false)
       private User user;
      
       @PersistenceContext
       private EntityManager em;
      
       @In(create=true)
       private transient FacesMessages facesMessages;
      
       @RequestParameter
       private String username;
      
       @RequestParameter
       private String action;
      
       @Logger
       private Log log;
      
       public String perform() {
      
       // Retrieve the user from the username
       user = ...;
      
       // Save action in the context
       Contexts.getConversationContext().set("action", this.action);
      
       return "home";
       }
      
       // Getters and Setters
       ...
      }


      The home.xhtml files is loaded properly and on onload call loads view.xml in another frame. The url used to load view.xhtml is:
      http://localhost:8080/default/view.seam?conversationId=#{conversation.id}

      Until this point, everything seems to be fine and I could check that the conversationId was properly passed in the url.

      Now in the view.xhtml page, there are some fields inside a form and a submit button defined with a s:link
      <s:link action="#{view.change}" value="submit" buttonClass="button" linkStyle="button"/>
      

      Where view is another stateless bean.

      @Stateless
      @Name("view")
      public class ViewAction implements View{
      
       @In
       @Out
       private User user;
      
       @PersistenceContext
       private EntityManager em;
      
       @In
       private transient Context sessionContext;
      
       @In(create=true)
       private transient FacesMessages facesMessages;
      
       @In
       private String action;
      
       private String definition;
      
       @Logger
       private Log log;
      
      
       public String change() {
      
       log.debug("****************** action: " + this.action);
       return null;
       }
      
       //Getters and Setters
       ...
      }


      I was expecting this.action not to be null but since I propagated the conversation all the way (I believe s:link does propagate the conversation as well).
      I thought by setting a value et putting it in the conversation context, it would be propagated, but it is not, so I guess I might do something wrong here, but I'm not sure what...

      If someone see what's wrong, I'd like to understand.

      Thanks

      Richard