Announcement Announcement Module
Collapse
No announcement yet.
How can I store values in session? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I store values in session?

    Hi,

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

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

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

    Comment


    • #3
      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

      Comment


      • #4
        Thank You!

        Comment


        • #5
          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?

          Comment


          • #6
            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

            Comment


            • #7
              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

              Comment


              • #8
                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

                Comment


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

                  Keith

                  Comment

                  Working...
                  X