0 Replies Latest reply on Jun 16, 2011 2:22 PM by lholmquist

    Remoting Model API and Conversations

    lholmquist Newbie

      I'm trying to use the remoting model api, but i'm running into a problem. 


      first i'm doing a simple seam authentication and triggering an event on a user object to store user information(similar to the booking example)


      i then created a @WebRemote method to get the user on the client side.


      here is some code:


        public @ConversationScoped class UserManager implements Serializable{
      
          @Inject
          Conversation conversation;
      
          private User user;
      
          @Produces
          @Authenticated
          @Named
          public User getUser()
          {
              return user;
          }
      
      
          @WebRemote
          public void onLoadUser()
          {
              System.out.println(user);
          }
      
          public void onLogin(@Observes @Authenticated User u)
          {
              conversation.begin();
              user = u;
      
          }
      



      and the javascript:




      var userModel = new Seam.Model();
      userModel.addBeanProperty("user","com.object.UserManager","user");
          userModel.fetch(action,loadingCallback);
      




      when i go to do the getValue method in my callback the user object it returns is null.  perhaps i am not setting the conversation correctly or does the remoting api not know about the conversation i started in the observer method. 


      I was able to create a work around where my UserManger is now session scoped and i inject that into another bean where my @webremote onLoadUser method is as well as the others.  the new onLoadUser method begins the conversation and stores the user object from the session in a different local user object.  when i make my other remote calls,  the conversation is populated with the value i expect.



      as a side question.  will the Remoting Model Api support sessionScoped stuff at some point



      thanks,  besides this little hiccup  i'm really enjoying seam 3


      -Luke