This content has been marked as final.
Show 3 replies
-
1. Re: Get and Set SessionInstance in ConversationInstance
nimo22 Nov 6, 2008 8:21 PM (in response to nimo22)This does not work:
@Name("conversationContext") @Scope(CONVERSATION) public class MyConversation { MySession mySession; @In(required=false) @Out (required = false) private List<String> sessionList; public void accessSessionContext() { //I want access to my sessionContext mySession = (MySession) Contexts.getSessionContext().get("sessionContext"); mySession.sessionList.add("hello"); }
Anything is wrong..
-
2. Re: Get and Set SessionInstance in ConversationInstance
nimo22 Nov 6, 2008 9:42 PM (in response to nimo22)Okay...now it works!!
I can get the Session-Instance from my Conversation-Instance:
first case:
sessionContext= (MySession) Contexts.getSessionContext().get("sessionContext"); sessionContext.getSessionList();
or I can get mySessionList directly:
second case:
List<String> mySessionList = (List<String>) Component.getInstance("mySessionList", ScopeType.SESSION);
both works.
But what, when I do not provide getter/setter in my sessionContext and use the first case. How can I retrieve mySessionList via my Contexts ?
sessionContext= (MySession) Contexts.getSessionContext().get("sessionContext"); sessionContext.XXX ?
-
3. Re: Get and Set SessionInstance in ConversationInstance
nimo22 Nov 6, 2008 10:26 PM (in response to nimo22)What is the difference of this. I invoke both in a Conversation-Scope:
List<String> myStrings = (List<String>) Component.getInstance("mySessionList", ScopeType.SESSION);
and that:
myStrings = (List<String>)Contexts.getSessionContext().get("mySessionList");
Is the shorter one, the better one?
Another point is, when I want to put some values into myString:
List<String> myStrings = (List<String>) Component.getInstance("mySessionList", ScopeType.SESSION); myStrings.add("hello");
then a NullPointerException occurs.
Any suggestions?