Announcement Announcement Module
Collapse
No announcement yet.
Accessing methods from beans in the Flow Scope Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    ${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

    Comment


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

      Comment


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

        Comment


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

          Comment

          Working...
          X