Results 1 to 9 of 9

Thread: How can I store values in session?

  1. #1
    Join Date
    Aug 2005
    Posts
    10

    Default How can I store values in session?

    Hi,

    How can I store values in session after successful execution of some action using webflow?

  2. #2
    Join Date
    Jul 2005
    Posts
    14

    Default

    I don't know if this is what you mean, but it should be something like this:

    context.getFlowScope().setAttributes( context.getSourceEvent().getParameters() );

  3. #3
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    If you want to store something in the HTTP session (the post above puts something in the flow scope), use this:

    Code:
    ((ServletEvent)context.getSourceEvent()).getRequest().getSession().setAttribute(...);
    Erwin

  4. #4
    Join Date
    Aug 2005
    Posts
    10

    Default

    Thank You!

  5. #5
    Join Date
    Aug 2005
    Posts
    10

    Default

    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?

  6. #6
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    potential red herring warning

    replace
    Code:
    c&#58;if test="$&#123;backRef ==\"1\"&#125;">
    with
    Code:
    c&#58;if test="$&#123;backRef =='1'&#125;">
    Might be nothing

  7. #7
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    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

  8. #8
    Join Date
    May 2006
    Posts
    15

    Default putting objects into HTTP Session

    I found this code in an earlier post and thought that answers my question about "How to put objects into the HTTP session":

    Code:
    ((ServletEvent)context.getSourceEvent()).getRequest().getSession().setAttribute(...);
    It seems that ServletEvent has been deprecated, so I used this approach:
    Code:
    context.getExternalContext().getSessionMap().put(EsConsts.FLOW_TYPE, flowId);
    That seems to do the job. Does anyone know if this is the proper way to do that?

    cheers
    challey

  9. #9
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    yes, that is correct, as per ref docs and javadocs.

    Keith
    Keith Donald
    Core Spring Development Team

Similar Threads

  1. OpenSessionInView and portlet support
    By garpinc2 in forum Web Flow
    Replies: 31
    Last Post: Apr 9th, 2010, 11:12 AM
  2. OpenSessionInView + CMT Session usage
    By alesj in forum Data
    Replies: 7
    Last Post: Aug 16th, 2005, 02:32 AM
  3. Replies: 2
    Last Post: May 5th, 2005, 09:35 PM
  4. Replies: 1
    Last Post: Mar 12th, 2005, 04:33 AM
  5. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •