Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: context.getModel() or other "session" data

  1. #1
    Join Date
    Nov 2004
    Location
    Düsseldorf, Germany
    Posts
    62

    Default context.getModel() or other "session" data

    What is the prefered way to store data in the webflow which should be accessed during the whole webflow? I know that there is the possibility to make a form with the scope FLOW but the information I have is completely unrelated to this form so I would like to store it independently.

    Think about a product name which is shown during a user registration wizard.
    It is loaded ones in the initial action and afterwards only displayed by the jsps. Normally I would put this as string in the session.

    Greetings,
    Markus

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

    Default

    Easy:

    From your action code:

    Code:
    context.getFlowScope().setAttribute("productName", myProductName);
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    I'm trying to figure out how to prepopulate a SELECT field for the first page of a flow. In the api for FormAction the last thing it says is
    Note that this action does not provide a referenceData() hook method similar to that of the SimpleFormController. If you need to setup reference data you should create a seperate state in your flow to do just that and make sure you pass through that state before showing the form view. Note that you can add the method that handles this reference data setup logic to a subclass of this class since this is a multi-action! Typically you would define an action execute method like

    public Event setupReferenceData(RequestContext context) throws Exception


    in that case.
    I don't understand how this setupReferenceData method will get called. I currently have
    Code:
    <webflow id="adminSignInFlow" start-state="adminSignInViewSetup">
        <action-state id="adminSignInViewSetup">
            <action bean="adminSignInViewSetup" method="setupForm" />
            <transition on="success" to="adminSignInView" />
        </action-state>
    Code:
    public class
    AdminSignInViewSetup extends FormAction &#123;
        public
        AdminSignInViewSetup&#40;&#41; &#123;
            setFormObjectClass&#40;AdminSignIn.class&#41;;
            setFormObjectName&#40;"adminSignIn"&#41;;
            setValidator&#40;new AdminSignInValidator&#40;&#41;&#41;;
            setFormObjectScope&#40;ScopeType.FLOW&#41;;
        &#125;
    &#125;
    (The ScopeType is there because I saw it somewhere and it looks cool. I'm not sure what it's doing. )

    (Finally let me don my hat of English grammar nanny nitpicker and point out some grammar and spelling errors. 1) It's sepArate, not sepErate. 2) Where you say "you need to setup" you're using the verb of SET UP, which is two words. You use SETUP when it's a noun, as in "you have a nice setup here".)

    Thanks again for all your help. I apologize for being such a dimbulb and needing to ask so many questions.

  4. #4
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    Hmm, a lightbulb just went off. :idea: Could I have my first action-state transition to another action-state that has only one method, setupReferenceData, and then that transitions to my view? I.e., insert an action-state between my existing first action-state and the subsequent view. It seems like that would work but is there a better way?

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

    Default

    Yes, either that or just use a view state setup action. See the setup subelement of the view-state element.

    Keith
    Keith Donald
    Core Spring Development Team

  6. #6
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default :)

    Great, thanks!

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

    Default

    Thanks for catching those typos in the JavaDoc. I fixed them!

    Erwin

  8. #8
    Join Date
    Dec 2004
    Location
    CA
    Posts
    208

    Default

    Greetings!

    Will be needing to lookup reference data as well.

    What is a "view state setup action" or "setup subelement"? Also what would be the Java-base flow equivalent?

    Is that similar to doing the following:


    addViewState (PRODUCT_UNIT_OF_MEASURE_PAGE_ID, PRODUCT_UNIT_OF_MEASURE_PAGE,
    new Transition[] {on(beforeExecute (method ("referenceData", action (ProductFormAction.class))),PRODUCT_FULLFILLMENT_P AGE)});

    _CJ

  9. #9
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default "setup" subelement

    If you know how to decode dtd files look at http://www.springframework.org/dtd/spring-webflow.dtd which comes from the doctype line at the top of your -flow.xml files.

    Dtd files are a dark mystery to me so I'd love to see an example use of the setup subelement.

  10. #10
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    Quote Originally Posted by curtney
    Greetings!... Also what would be the Java-base flow equivalent?
    Also, what's the motivation for using a java based flow? I was puzzled about why the Spring Web Flow "Practical Guide" spent so much time explaining that.

Similar Threads

  1. Replies: 2
    Last Post: Oct 18th, 2005, 10:08 AM
  2. How to persist model data in session
    By thenakedsingularity in forum Web
    Replies: 8
    Last Post: Aug 4th, 2005, 01:04 PM
  3. Multiple Data Sources + Hibernate + Spring
    By joeserel in forum Data
    Replies: 2
    Last Post: May 18th, 2005, 09:22 AM
  4. injecting complex configuration data
    By fox9 in forum Container
    Replies: 2
    Last Post: Feb 25th, 2005, 07:23 AM
  5. Data Secutiry - Filtering Data
    By porcelli in forum Security
    Replies: 3
    Last Post: Dec 30th, 2004, 12:01 AM

Posting Permissions

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