Announcement Announcement Module
Collapse
No announcement yet.
I think I I think I found a bug with webflow + Rob's form tags Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • I think I I think I found a bug with webflow + Rob's form tags

    I have a shared JSP page that uses the new spring form tags. The page is used in 2 spots. It's used once by a normal Spring SimpleFormController and once by a web flow using a FormAction class.. For some reason, only when using webflow, the form tag isn't binding properly to my model in the request.

    For example my JSP is (simplified):
    Code:
    ${address}
    
    <%
        Address addr = (Address) request.getAttribute("address");
        System.out.println("***\n\n" + "address: " + addr + "\n\n***");
    %>
    <spring-form:form commandName="address">
    
    <table>
        <tr>
            <td>Contact Name:</td>
            <td><spring-form:input path="contactName"/></td>
        </tr>
    </table>
    </spring-form:form>
    When running this code using the normal spring MVC controllers, the form binds properly when editing an existing address as seen on the actual form input elements and the printouts from the ${address} and the system out.

    Now switch over to using webflow, the address is still being printed by both the ${address} line and the system out line in the JSP but it seems that the form tag isn't finding the command object in the request. Clearly the address object is in the request because the JSP is pulling it out via 2 different methods.

    My FormAction is defined as:
    Code:
        <bean id="configureAddressFormAction" class="com.vodori.dolce.web.flow.form.ConfigureAddressForm">
            <property name="accountManager" ref="accountManager"/>
            <property name="formObjectName" value="address"/>
            <property name="formObjectClass" value="com.vodori.dolce.component.common.model.Address"/>
            <property name="formObjectScope" value="REQUEST"/>
            <property name="propertyEditorRegistrar" ref="customPropertyEditorRegistrar"/>
            <property name="formErrorsScope" value="REQUEST"/>
        </bean>
    Forgive me if I have missed something but it seems like a bug when the behavior is different between the web flow and a normal spring form controller.

    Thanks!
    Last edited by GrantGochnauer; Jul 12th, 2006, 02:45 PM.

  • #2
    Grant,

    Did you call setupForm on your FormAction before entering your view-state to render the view? I'm pretty sure it's not just "address" that the target looks for, but a special address "errors" object under a internal key... setupForm sets up that internal entry.

    Keith

    Comment


    • #3
      I did.. My flow definition is:

      Code:
       <view-state id="editDeliveryAddress" view="enterDeliveryAddressesOnCheckoutLanding">
              <entry-actions>
                  <action bean="configureAddressFormAction" method="setupForm"/>
              </entry-actions>
              <transition on="submit" to="displayDeliveryAddresses">
                  <action bean="configureAddressFormAction" method="bindAndValidate">
                  </action>
              </transition>
          </view-state>
      and my setupForm method is:
      Code:
      @Override public Event setupForm( RequestContext requestContext ) throws Exception
          {
              super.setupForm(requestContext);
              requestContext.getRequestScope().put("directions", Address.getStreetDirections());
      
              String addressId = requestContext.getRequestParameters().get("addressId");
      
              _logger.debug("#### " + "Found Address ID: " + addressId);
      
              if (StringUtils.hasText(addressId))
              {
                  // We are editing an existing address.
                  int addrId      = Integer.parseInt(addressId);
                  Address address = getAccountManager().getAddress(addrId);
      
                  _logger.debug("#### " + "putting address into scope: " + address);
                  requestContext.getRequestScope().put("address", address);
                  requestContext.getConversationScope().put("address", address);
                  requestContext.getExternalContext().getRequestMap().put("address", address);
              }
      
              return success();
          }
      I am trying to expose the address object 3 different ways just for testing purposes but none seems to work at the moment..Perhaps I am exposing the "address" object properly to the page?

      Thanks!

      Comment


      • #4
        Grant,

        I see no reason why this can't work. Can you do me a favour and package up your files and bash out a JIRA issue? I'll use this as a base to write some tests and get this fixed.

        Cheers,

        Rob

        Comment


        • #5
          Sure thing Rob. I'll do that tonight.

          Thanks!

          Comment


          • #6
            Issue created:
            http://opensource.atlassian.com/proj...rowse/SPR-2289

            Comment


            • #7
              Grant,

              I know you're overriding setupForm but can you do me a favor and try it with it out overridden and see what happens.

              In general, I would recommend exposing separate action methods and calling them in a chain rather than overriding (but that is a separate issue of course).

              I would also recommend turning on debug logging just to get familiar what is going on when setupForm is called.

              Keith

              Comment

              Working...
              X