View Full Version : How can I store values in session?
nlatha
Aug 9th, 2005, 09:27 AM
Hi,
How can I store values in session after successful execution of some action using webflow?
ruipacheco
Aug 9th, 2005, 10:59 AM
I don't know if this is what you mean, but it should be something like this:
context.getFlowScope().setAttributes( context.getSourceEvent().getParameters() );
klr8
Aug 9th, 2005, 01:24 PM
If you want to store something in the HTTP session (the post above puts something in the flow scope), use this:
((ServletEvent)context.getSourceEvent()).getReques t().getSession().setAttribute(...);
Erwin
nlatha
Aug 9th, 2005, 01:38 PM
Thank You!
nlatha
Aug 9th, 2005, 01:55 PM
Hi ,
I used the following code
((Scope)(context.getFlowScope())).put("backRef","1");
Once I set the variable I am able to access successfully in jsp page as follows
c:if test="${backRef ==\"1\"}">
<a href="journal.toc?_flowExecutionId=${flowExecutionId}&_eventId=selectBackRef">Select Article</a>
</c:if>
It’s working fine. But I replaced
((Scope)(context.getFlowScope())).put("backRef","1"); with
((ServletEvent)context.getSourceEvent()).getReques t().getSession().setAttribute(("backRef","1");
and it’s not working, backRef attribute is coming as null in jsp page.
Am I missing anything?
Colin Yates
Aug 10th, 2005, 04:27 AM
potential red herring warning ;)
replace
c:if test="${backRef ==\"1\"}"> with
c:if test="${backRef =='1'}">
Might be nothing ;)
klr8
Aug 12th, 2005, 06:25 AM
All data in flow scope and request scope is made available to the JSP as request attributes, so you can simply do things like '<c:out value="${backRef}"/>'.
However, the content of the HTTP session is not directly available in the request attributes, so in that case you should do: '<c:out value="sessionScope.backRef"/>'.
Note that this is not related to the use of SWF. Read a few articles about the Servlet API and JSTL to find out more.
Erwin
challey
Jun 9th, 2006, 06:08 AM
I found this code in an earlier post and thought that answers my question about "How to put objects into the HTTP session":
((ServletEvent)context.getSourceEvent()).getReques t().getSession().setAttribute(...);
It seems that ServletEvent has been deprecated, so I used this approach:
context.getExternalContext().getSessionMap().put(E sConsts.FLOW_TYPE, flowId);
That seems to do the job. Does anyone know if this is the proper way to do that?
cheers
challey
Keith Donald
Jun 9th, 2006, 08:07 AM
yes, that is correct, as per ref docs and javadocs.
Keith
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.