Hi,
How can I store values in session after successful execution of some action using webflow?
Hi,
How can I store values in session after successful execution of some action using webflow?
I don't know if this is what you mean, but it should be something like this:
context.getFlowScope().setAttributes( context.getSourceEvent().getParameters() );
If you want to store something in the HTTP session (the post above puts something in the flow scope), use this:
ErwinCode:((ServletEvent)context.getSourceEvent()).getRequest().getSession().setAttribute(...);
Thank You!
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=${flowExecution Id}&_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?
potential red herring warning
replacewithCode:c:if test="${backRef ==\"1\"}">Might be nothingCode:c:if test="${backRef =='1'}">![]()
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
I found this code in an earlier post and thought that answers my question about "How to put objects into the HTTP session":
It seems that ServletEvent has been deprecated, so I used this approach:Code:((ServletEvent)context.getSourceEvent()).getRequest().getSession().setAttribute(...);
That seems to do the job. Does anyone know if this is the proper way to do that?Code:context.getExternalContext().getSessionMap().put(EsConsts.FLOW_TYPE, flowId);
cheers
challey
yes, that is correct, as per ref docs and javadocs.
Keith
Keith Donald
Core Spring Development Team