Announcement Announcement Module
Collapse
No announcement yet.
Cannot put an object into request without a form? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot put an object into request without a form?

    For some reason, if I do not bind a form to a flow, I cannot seem to get any objects to be put in the request for display on the JSP..

    For example, in my MultiAction class - method: "putOrderIntoRequest", I have:
    Code:
    requestContext.getRequestScope().put("order", getOrder());
    My XML definition is:
    Code:
    <view-state id="displayDeliveryAddresses" view="manageDeliveryAddressesLanding">
            <entry-actions>
                <action bean="deliveryAddressMultiaction" method="putOrderIntoRequest"/>
            </entry-actions>
            <transition to="finish" on="deliverHere"/>
        </view-state>
    There is no form on the view page, I just have a few buttons that allow a user to choose an address. However, in my JSP, the "order" object in the request is null..

    any ideas?

    Thanks!

  • #2
    Are you doing a redirectOnPause when your view state is entered? Request scope will be lost since the redirect is on a new request (we could consider turning it into flash scope for that use case, or introducing a flash scope concept).

    IF not, are you sure getOrder() doesn't return null?

    Keith

    Comment


    • #3
      My getOrder() is returning an object.. I am printing it out with a logging statement and I am not using "redirectOnPause". However, this flow is a subflow of a larger flow so I'm not sure if that might make a difference? What is interesting is that if I use:

      Code:
      requestContext.getConversationScope().put("order", getOrder());
      then I can use the ${order} in my JSP. Odd...

      This is with 1.0RC3.

      Thanks,
      Grant

      Comment


      • #4
        That should not make a difference. Request scope is simply linked to ta request into the flow execution and has nothing to with flow relationships.

        So the JSP you'are talking about is "manageDeliveryAddressLanding" right, the one displayed right after the entry action is executed in the same request.

        The only thing I can think is the JSP's model by default consists of: request scope + flow scope + conversation scope in that order. So if there were two objects with the same "order" key in the different scopes one would overwrite the other. I'd recommend checking your selected ApplicationView's model when the view state is entered--either via the debugger or with debug logging turned on.

        I'll create a simple test case to try and reproduce this. I admit I would be surprised if it turns up a problem but I'll definitely check!

        Keith
        Last edited by Keith Donald; Jul 8th, 2006, 10:54 AM.

        Comment


        • #5
          I haven't been able to reproduce this... here's my test case which passes:

          Code:
          public class MiscFlowExecutionTests extends TestCase {
              public void testRequestScopePutInEntryAction() {
                  Flow parentFlow = new Flow("parent");
                  Flow flow = new Flow("test");
                  SubflowState parentState = new SubflowState(parentFlow, "parentState", flow);
          
                  ViewState state = new ViewState(flow, "view");
                  state.setViewSelector(new ApplicationViewSelector(new StaticExpression("myView")));
                  final Object order = new Object();
                  state.getEntryActionList().add(new AbstractAction() {
                      protected Event doExecute(RequestContext context) {
                          context.getRequestScope().put("order", order);
                          return success();
                      }
                  });
                  FlowExecution execution = new FlowExecutionImpl(parentFlow);
                  ApplicationView response = (ApplicationView)execution.start(null, new MockExternalContext());
                  assertNotNull(response.getModel().get("order"));
                  assertEquals(order, response.getModel().get("order"));
              }
          }
          Here's resulting debug logging:

          Code:
          2006-07-08 11:11:39,340 DEBUG [org.springframework.webflow.execution.impl.FlowExecutionImpl] - <Created new execution of flow 'parent'>
          2006-07-08 11:11:39,433 DEBUG [org.springframework.webflow.execution.impl.RequestControlContextImpl] - <Activating new session for flow 'parent' in state 'parentState' with input map[[empty]]>
          2006-07-08 11:11:39,433 DEBUG [org.springframework.webflow.execution.impl.FlowExecutionImpl] - <Starting [FlowSessionImpl@406199 flow = 'parent', state = '[none]', scope = map[[empty]]]>
          2006-07-08 11:11:39,433 DEBUG [org.springframework.webflow.SubflowState] - <Entering state 'parentState' of flow 'parent'>
          2006-07-08 11:11:39,433 DEBUG [org.springframework.webflow.execution.impl.FlowSessionImpl] - <Setting current state of 'parent@406199' to 'parentState'>
          2006-07-08 11:11:39,433 DEBUG [org.springframework.webflow.SubflowState] - <Spawning subflow 'test' within flow 'parent'>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.SubflowState] - <No attribute mapper configured for this subflow state 'parentState' -- As a result, no attributes will be passed to the spawned subflow 'test'>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.execution.impl.RequestControlContextImpl] - <Activating new session for flow 'test' in state 'view' with input map[[empty]]>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.execution.impl.FlowExecutionImpl] - <Starting [FlowSessionImpl@5329c5 flow = 'test', state = '[none]', scope = map[[empty]]]>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.ViewState] - <Entering state 'view' of flow 'test'>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.execution.impl.FlowSessionImpl] - <Setting current state of 'test@5329c5' to 'view'>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.ActionExecutor] - <Executing org.springframework.webflow.execution.MiscFlowExecutionTests$1@107ebe1 in state 'view' of flow 'test'>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.execution.MiscFlowExecutionTests$1] - <Action 'MiscFlowExecutionTests.1' beginning execution>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.execution.MiscFlowExecutionTests$1] - <Action 'MiscFlowExecutionTests.1' completed execution; result is 'success'>
          2006-07-08 11:11:39,449 DEBUG [org.springframework.webflow.execution.impl.FlowExecutionImpl] - <Paused to render [ApplicationView@11a64ed viewName = 'myView', model = map['order' -> java.lang.Object@8bdcd2]] and wait for user input>
          As you can see 'order' is there...
          Last edited by Keith Donald; Jul 8th, 2006, 11:18 AM.

          Comment


          • #6
            Well, with a little debugging, I found the problem. Turns out I had an old copy of my spring servlet.xml which DID have the redirectOnPause set to true even though in my IDE it was false. Sorry for the stupid mistake

            I appriecate the quick responses though Keith!

            -Grant

            Comment

            Working...
            X