0 Replies Latest reply on Jun 1, 2007 3:07 PM by viniciuscarvalho

    Seam + Remoting + ajax4jsf question

    viniciuscarvalho

      Hello there! I'm trying these combination, and I'm bit confused with the mix, hope someone help me out.

      I'm using a Stateful bean that has a property:

      @Stateful
      @Name("userService")
      @Scope(SESSION)
      public class UserServiceBean implements UserSession{
      private User user;
      //this is a webremote method
      public void setUser(int id){
      this.user = em.find....
      }
      public User getUser()
      }
      


      So it's a pretty easy simple bean right :)

      The user clicks in a event that triggers the SeamRemoting method:
      userService = Seam.Component.getInstance("userService");
      userService.setUser(id);
      


      So far so good, method is triggered and user is bound to the bean. So The user clicks on another component that uses ajax4jsf to re-render a panel:
      <img onclick="reDraw()"/>
      <h:form>
      <a4j:jsFunction name="redraw" data="#{userService.user}" reRender="userPanel"/>
      <h:form>
      <rich:panel id="userPanel">
      ... contents
      </rich:panel>
      


      Now, what happens is that the getUser returns an empty user (as if it is an new invocation) If I call the set user, then reload the page, the user is still null. Seems that the Stateful bean is not being bound to the same client, ajax calls seems to be a different cllient to the container.
      I'm really confused on how to bind the ajax invocations to the stateful bean.

      Could someone give me some directions?

      Regards