Question

I currently have a Spring Webflow application that uses Webflow + Ajax.

I have a view-state called "A" that has several transitions.

<view-state id="A" model="myClass">
    <transition on="X1" .../>
    <transition on="X2" .../>
    <transition on="X3" .../>
</view-state>

The problem is that each transition should validate only a portion of "myClass" and not all. By default Spring Webflow has a single method to validate.

Basically what I need is to call a different validate method on each transition instead of having a single one.

Is this possible? Any ideas on how to do this?

Thanks in advance!!!

Was it helpful?

Solution

Why not use one ValidationClass for view state? You can get the event that triggert the validation by calling

public String getUserEvent();

on the ValidationContext. Then, depending on the result do whatever you want to validate.

OTHER TIPS

It is possible to use an attribute called validatorMethod to specify a particular method to call on the validator as described here. Here is a modified example from the Javadoc showing how do do this:

<view-state id="displayCriteria">
    <on-render>
        <evaluate expression="formAction.setupForm"/>
    </on-render>
    <transition on="search" to="executeSearch">
        <evaluate expression="formAction.bindAndValidate">
            <attribute name="validatorMethod" value="validateSearchCriteria"/>
        </evaluate>
    </transition>
</view-state>

This is assuming that the validator defined for searchFormAction has a method called validateSearchCriteria.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top