Announcement Announcement Module
Collapse
No announcement yet.
Need help with configuring validation for webflows with SWF 2.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help with configuring validation for webflows with SWF 2.0

    I am facing problems with spring web flow validation, with SWF 2.0.

    For SWF 1.0, you could declare the action beans inside the action state, this is the example for declaring the action state in flow configuration files


    <action-state id="bindAndValidateCriteria">
    <action name="bindAndValidateAct" bean="bindAndValidateCriteriaAction"/>
    <transition name="bindAndValidateAct.ok" to="search"/>
    <transition name="bindAndValidateAct.error" to="criteria"/>
    </action-state>


    But with SWF 2.0 you can’t declare action tag inside the action state so I do not understand how to declare any specific class or bean there which can take care of validation like the bindAndValidateCriteriaAction bean, which is handling validation in my the SWF 1.0-based action-state xml configuration.

    So using SWF 2.0, I did find some spring web flow reference documentation to validate any object, so I have proceeded with that approach. Below is a sample configuration that I am doing

    <view-state id="editProduct" model="product" view="products/edit">

    <binder>
    <binding property="productId" required="true" />
    <binding property="productName" required="true" />
    <binding property="productDescription" required="true" />
    </binder>

    <transition on="save" validate="true" to="save">

    <evaluate expression="myDBService.createProduct()"
    result="flowScope.product" />
    </transition>
    <transition on-exception="java.lang.Exception" to="error"></transition>
    <transition on="cancel" to="cancel" bind="false" />
    </view-state>

    According to the spring documentation the flow should search for the class whose name
    “ProductValidator” because my model name in the given view state is “product” and it should invoke a specific method given that the view state id is “editProduct”.

    So, I have created a class called “ProductValidator”, with the following method:

    Public boolean validateEditProduct(Product product,ValidationContext context)

    However, somehow, the “validateEditProduct” method is not being invoked. I do not know what I am doing wrong. Please help with this problem. Please explain if I am missing something or if there is anything more that I need to configure in order to get it done. I would appreciate any additional pointers in the spring web flow 2.0 documentation, and ideally some example that successfully demonstrates validation with SWF 2.0.

    Thanks for your help in advance…
Working...
X