Results 1 to 5 of 5

Thread: Accessing methods from beans in the Flow Scope

Hybrid View

  1. #1
    Join Date
    May 2005
    Location
    Fallbrook, CA
    Posts
    22

    Default Accessing methods from beans in the Flow Scope

    I seem to be having some trouble accessing the methods of a bean (ArrivalRequest) I have placed in the flow scope from a view.

    In the first Action-state I call a bean that contains the following code in its doExecute method:

    Code:
    ArrivalRequest req = new ArrivalRequest();
    context.getFlowScope().setAttribute("arrivalRequest",req);
    In the action-state that follows the view-state that is called by the above action-state I call a setter method in that bean using the following code so I know it is there and accessible:

    Code:
    ((ArrivalRequest)context.getFlowScope().getAttribute(
       "arrivalRequest")).setServiceBoard(new Integer(serviceBoard));
    Using jsp or Velocity syntax, how would I reference the getServiceBoard method of the arrivalRequest bean?

    I have tried (in Velocity):

    Code:
    ${flowScope.getAttribute("arrivalRequest").getServiceBoard()}
    and

    Code:
    ${flowScope.arrivalRequest.serviceBoard}

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

    Default

    ${arrivalRequest.serviceBoard} -- attributes in flow scope are exposed to the view directly before the view is asked to render.

    With the latest in CVS you can access any contextual information about the flow using ${flowContext.<whatever} -- see the FlowContext interface. You can do this with PR3 as well, you just have to use the "flowExecution" attribute which really should be named "flowContext" (we've done a rename there for PR4.)

    Keith
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    May 2005
    Location
    Fallbrook, CA
    Posts
    22

    Default Been there, Done that

    Well, I don't know if its Velocity that's messing me up or what but I've tried that syntax (${arrivalRequest.serviceBoard}) but Velocity is logging a warning that its not a valid reference.

    BTW, I am running SWF PR3.

  4. #4
    Join Date
    May 2005
    Location
    London, UK
    Posts
    21

    Default

    You could try and write a bit of scriptlet in a jsp to help determine whether there is a problem with your Velocity set up. e.g.
    Code:
    <%=&#40;&#40;com.foo.ArrivalRequest&#41;request.getAttribute&#40;"arrivalRequest"&#41;&#41;.getServiceBoard&#40;&#41; %>
    I tried your example using jsp's and it seems to work fine.

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

    Default

    Are you using velocity with Spring MVC for view resolution? I made the assumption you were. It handles exporting stuff in flow scope to the request for convenient access by the template.
    Keith Donald
    Core Spring Development Team

Similar Threads

  1. FlowExecutionStorage in a DB
    By cacho in forum Web Flow
    Replies: 7
    Last Post: Oct 19th, 2009, 03:36 PM
  2. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  3. Is a 'singleton' flow a bad idea?
    By akw in forum Web Flow
    Replies: 4
    Last Post: Oct 6th, 2005, 01:16 AM
  4. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  5. Accessing beans from static methods
    By Agardner in forum Container
    Replies: 5
    Last Post: Jun 23rd, 2005, 06:10 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
  •