Announcement Announcement Module
Collapse
No announcement yet.
how to access scoped variables in jsp? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to access scoped variables in jsp?

    If I wanted to access a variable (other than flow/flash scoped) in a jsp, is there another way to access it other than using flowExecutionContext?

  • #2
    Webflow exposes the view model provided in the view-state definition and all conversation scoped variables to the view including;
    • conversation scope
    • flow scope
    • view scope
    • flash scope
    • request scope
    Additionally, webflow provides access to:
    • the user's principal security object (through 'currentUser')
    • the flow request context (through 'flowRequestContext') providing a variety of contextual information about the current flow context (current state, possible transitions, etc...)
    • the flow execution key identifying the current flow (through 'flowExecutionKey')
    • the flow execution url identifying the path to the current flow (through 'flowExecutionUrl')
    Can you be more specific about what variable you're trying to access and where it lives?

    Ta,
    Paul

    Comment


    • #3
      Conversation Scope example

      Paul,

      Lets say I had a variable called "foo" in the conversation scope. How would I be able to access its value from inside a JSP?

      Comment


      • #4
        From within JSP, use the Expression Language (EL):

        Code:
        ${foo}
        Or if the value is a property within a 'foo' object:

        Code:
        ${foo.someValue}
        Ta,
        Paul

        Comment


        • #5
          Originally posted by Paul Wilson View Post
          From within JSP, use the Expression Language (EL):

          Code:
          ${foo}
          Or if the value is a property within a 'foo' object:

          Code:
          ${foo.someValue}
          Ta,
          Paul
          Hi,
          this is from flow to jsp!
          and from jsp to flow? how i can do it?

          Comment


          • #6
            I get nothing

            Paul,

            The only scoped variables I am able to access this way are flow conversation and flash scoped variables. I suspect this is because they are backed by http session. The get nothing for variables in other scopes.

            I have been unable to find any documentation that says that variables in the different scopes are made available to JSP's this way. Have you seen where this behavior is documented?

            Comment


            • #7
              I can see in the code where the various scopes are getting merged into the request context before it's forwarded to the JSP.

              Sounds like you need to post examples of what you're actually doing, along with configuration.

              Comment


              • #8
                Paul,

                Where in the code does this happen?

                Comment


                • #9
                  In
                  Code:
                  AbstractMvcView#render()

                  Comment


                  • #10
                    Originally posted by Paul Wilson View Post
                    From within JSP, use the Expression Language (EL):

                    Code:
                    ${foo}
                    Or if the value is a property within a 'foo' object:

                    Code:
                    ${foo.someValue}
                    Ta,
                    Paul
                    Hi,
                    this is from flow to jsp!
                    and from jsp to flow? how i can do it?

                    Comment


                    • #11
                      Hi Miky,

                      Read the section on binding in the webflow docs:

                      http://static.springsource.org/sprin...l/ch05s06.html

                      Essentially, when the HTML page generated by your JSP 'submit's back to the webflow system, it takes the input variables from the form (present in the POST) and sets their values back to your model object.

                      Have you tried looking at the webflow samples?

                      Comment


                      • #12
                        Hi Paul,
                        i have a list of item and every item have a radio button...the user must select one radio button, and the value of the radio button chosen, must go to another jsp page throught flow.

                        the value of radio button, is initially populated dynamically through a flow...
                        so, how i can pass the value of the radio buttom chosen from jps to flow?

                        thank you

                        Comment


                        • #13
                          The radio button should have a name and a value associated with it. The name should map to a property on your model object, and the value is what's assigned to that if the user selects it prior to submit.

                          Seriously, look at the webflow samples because there's an example of this in there.

                          Comment


                          • #14
                            which example?

                            thank you so much

                            Comment


                            • #15
                              For example, the 'Search Criteria' facility uses radio buttons to select the page size for the search (in the booking-mvc example). Take a look at the model object SearchCriteria.java and the searchForm.jsp which binds to it.

                              Comment

                              Working...
                              X