Search code examples
javaspringjakarta-eespring-webflow

Having problems with Spring webflow


I am trying to add a on-render element to this XML:

<var name="someVariable" class="com.example.test"/>

<view-state id="frontpage" view="test/test">    
    <binder>
        <binding property="test" required="true"/>
    </binder>     
    <transition on="submit" to="summary">
        <evaluate expression="myExpression.test()"/>
    </transition>
</view-state>

I tried adding it in the view-state element, but when I do so, the page crash. This is the exception:

org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'binder'. One of '{"http://www.springframework.org/schema/webflow":transition, "http://www.springframework.org/schema/webflow":on-exit, "http://www.springframework.org/schema/webflow":exception-handler}' is expected.

I am using Spring webflow 2.0.8.


Solution

  • The WebFlow XSD specifies that any <binder> element must come before any <on-render> element. The exception message you got is because your on-render element was appearing before the <binder> element. I suggest that you use an XSD-aware editor for editing XML files, and include the webflow XSD in the XML declaration:

    <?xml version="1.0"?>
    <flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
          start-state="startState">
    
    ...
    
    </flow>