0 Replies Latest reply on Sep 13, 2007 11:57 AM by jfrankman

    When to use Session scope vs. Conversation

    jfrankman Novice

      I have an intranet web application for handling our companies clients. After the user searches for and selects a client, the user to brought to the ?Client Master? page. This page consists of a tree control on the left and an iframe on the right. As the user clicks a node on the tree the proper page corresponding to the node is displayed in the iFrame. Right now I have declared by Client object to have session scope.

      public class ClientVO implements Serializable

      The actions for the pages are handled by a stateful session bean where I try to load the entire object graph for the client when the Client Master page is loaded

      public class ClientActionImpl implements ClientAction
       //@PersistenceContext(type=PersistenceContextType.EXTENDED) EntityManager em;
       @In(create=true) private ClientService clientService;
       @In(required=false) @Out(required=false) ClientVO client;
       @In @Out(required=false) PolicyVO policy;
       @In(required=false) ClientVO subClient;
       @In(required=false) MasterSearchResultVO searchResult;
       @In(required=false) @Out(required=false,scope=ScopeType.SESSION) ClientVO parentClient=new ClientVO();;
       @Out(scope=ScopeType.SESSION) Boolean organizationFlag=false;
       @Out(scope=ScopeType.SESSION) Boolean personFlag=true;
       @Logger Log log;
       public String lookupClientFromSearch() {
       if (client instanceof PersonVO)
       else if (client instanceof OrganizationVO)
       System.out.println("The Client is a only a ClientVO");
       log.info("In Client Lookup(log)");
       return "success";

      I use session scope because while the user is on the Client Master page all pages loaded in the iFrame would need access to the Client object. I have found that by doing this I run into a lot of Lazy init errors. I basically have to get the Client key and fetch the entire Object graph. This works ok for now, but I fear that this could be a problem in the future. Plus from my reading about conversations it looks like I would not have to worry about the Lazy Init errors if the Client object was in conversational scope.

      I have a few questions about this:

      1. Is there a way to properly end a conversation when there is not really any linear page flow? In other words, I understand how a conversation would work in a shopping cart or wizard where a user is moved sequentially from one page to another. However in my case where there is a tree control and iframe the user could navigate to numerous pages in any particular order. How would I end the conversation when a user chooses to exit the Client Master Screen?

      2. In cases where numerous operations can be performed on the client from various unordered screens would it be better that I stick with Session scope? In other words is the conversation scope best suited for wizards and ordered/sequential page navigation, or can I some how use in Client Master page in conversational scope. Or, am I better off sticking with Session scope.

      3. When a converstion or session ends in the iframe is there a way to show the error.xhtml page in the parent browser window rather than the iframe?
      4. Are 1-4 hour sessions/conversations acceptable for Intranet applications? Assume that this is an intranet application. It could have up to 200-400 concurrent users but never any more that that. They will need long running sessions or conversations. When an employee walks away from the application for one or two hours they don?t want to have to sign back into the application

      I am trying to learn as much as possible, so any help would be appreciated.