0 Replies Latest reply on Sep 13, 2006 11:56 AM by mauro.lopez

    Seam remoting on portal, session scope problem

      I've a component with session scope, i.e.:

      @Scope(ScopeType.SESSION)
      @Name("myComponent")
      public class MyComponent {
       ...
      }
      

      An this other component, with a remote method and a dependency to the above component:

      @Name("someAction")
      public class MyAction {
      
      
       @WebRemote
       public void doSomethingWithMyComponent() {
       ...
       myComponent.doSomething();
       ..
       }
      
       @In(required = false)
       MyComponent myComponent;
      
       ...
      }
      
      


      The above is used as follows (remember I'm developing a portlet):

      1. At some point in the application flow, "myComponent" is instantiated (and put in session context).
      2. Some page does an ajax request to MyAction.doSomethingWithMyComponent() through seam remoting.
      3. well.... doesn't matter.

      The fail comes at step 2, there a NPE is thrown, and the cause is myComponent is not injected! Well, really it is injected, but there happens to be no "myComponent" in session scope, so the component created in step 1 is not the one injected (I get a null due to @In(required = false)).

      I've found that web remote seam components are invoked through the same url used for static resources (in JSR-168 perspective), which is correct, because neither a render url nor an action url would work alright since the portlet response (ajax requests's xml response) would be composed with other portlets' markup.
      (now I think, the encodeUrl method shouldn't be used to build the ajax request url?)

      The problem, I think, is that resource URLs are outside the portlet context, therefore the Portlet Session context is not available. Instead, what we've got is the HttpSession.

      The component named "myComponent" can not be found in the HttpSession.

      As JSR-168 states (PLT.15.4), the Portlet Session stores attributes in the HttpSession, but prefixed, that's why seam can't find it.


      are there any plans to provide better support for remoting in a portal?



      There seems to be two possibilities:
      1. Wait for jboss portal ajax requests support, and integrate seam with it. See http://www.jboss.com/index.html?module=bb&op=viewtopic&t=90035&postdays=0&postorder=asc&start=20
      2. Manage to recover the components when stored in prefixed HttpSession attributes. (through PortletSessionUtil). In this case, something should tell seam that the component was stored in X Portlet Session.


      Thank you.