Announcement Announcement Module
Collapse
No announcement yet.
Problem getting spring:bind to work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem getting spring:bind to work

    I have been beating my head against this for too long, so hopefully I can get some help. When my Webflow-backed web form is displayed, I am seeing "${status.value}" in the text fields. And when I look at the document source, I see "${flowExecutionId}" as the value for the hidden "_flowExecution" field.

    I have Spring Framework 1.2.5, and Webflow PR5.

    The link I use to get to the form is: bed.html?_flowId=dataObject-flow

    Here is my servlet.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org
    /dtd/spring-beans.dtd">
    
    <beans>
      <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalRe
    sourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
      </bean>
    
      <bean name="/bed.html"
              class="org.springframework.webflow.mvc.FlowController" />
    
      <bean id="dataObject-flow"
    class="org.springframework.webflow.config.XmlFlowFactoryBean">
        <property name="location" value="/WEB-INF/dataObject-flow.xml"/>
      </bean>
    
    <!--
      <bean id="showFormAction"
    class="org.springframework.webflow.action.FormAction">
        <property name="formObjectName" value="dataObject"/>
    
        <property name="formObjectClass" value="model.DataObject"/>
        <property name="formObjectScopeAsString" value="flow"/>
      </bean>
    -->
    
      <bean id="showFormAction" class="flow.TestFormAction" />
    
    </beans>
    Here is my webflow definition (pretty basic, since I can't get past the spring:bind issue):
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE webflow PUBLIC "-//SPRING//DTD WEBFLOW//EN"
            "http&#58;//www.springframework.org/dtd/spring-webflow.dtd">
    
    <webflow id="dataObject-flow" start-state="displayForm">
    
      <view-state id="displayForm" view="showForm">
        <entry>
          <action bean="showFormAction" method="setupForm"/>
        </entry>
        <transition on="submit" to="displayResults"/>
      </view-state>
    
      <end-state id="displayResults" view="end" />
    
    </webflow>
    And here is the JSP page for the form:
    Code:
    <%@ include file="/WEB-INF/jsp/include.jsp" %>
    
    <html>
    <head><title>Data Object Form</title></head>
    
    <body>
      <h1>Data Object Form</h1>
    
      <form name="showForm" method="post">
        <spring&#58;bind path="dataObject.name">
          <b>Name&#58;</b> 
            <input type="text" name="$&#123;status.expression&#125;" value="$&#123;status.value&#125;">
        </spring&#58;bind>
        <spring&#58;bind path="dataObject.desc">
          <b>Description&#58;</b>
            <input type="text" name="$&#123;status.expression&#125;" value="$&#123;status.value&#125;">
        </spring&#58;bind>
        <input type="hidden" name="_flowExecutionId" value="$&#123;flowExecutionId&#125;">
        <input type="submit" class="button" name="_eventId_submit" >
      </form>
    </body>
    </html>
    The DataObject class just has two String variables ("name" and "desc") along with gettors and settors. The TestFormAction class just has a constructor method.

    Any enlightenment that can be provided will be appreciated. Any debugging hints will also be accepted.

    Coey

  • #2
    Are you using a JSP 2.0 / Servlet 2.4 compatible app server (what are you using)? Even if you are, and you're specifying the wrong version in the web.xml top-level element, this could happen.

    Code:
    <web-app id="app_name" version="2.4" xmlns="http&#58;//java.sun.com/xml/ns/j2ee" xmlns&#58;xsi="http&#58;//www.w3.org/2001/XMLSchema-instance" xsi&#58;schemaLocation="http&#58;//java.sun.com/xml/ns/j2ee http&#58;//java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    With anything pre jsp 2.0 / servlet 2.4, you'll have to use <c:out value="${status.value}" /> instead of embedding the jsp-el arbitrarily in the jsp.

    Cheers,
    Christian

    Comment


    • #3
      That was it. I am using Apache Tomcat 5.5.9, but I completely missed the extra stuff in the web.xml in all the samples.

      I have gotten my testbed app. running, first by adding the appropriate "<c:out>" structures, then by going back and just up'ing the declared version to 2.4 (and removing the added "<c:out>" stuff).

      Thanks!

      Coey

      Comment

      Working...
      X