Search code examples
ajaxspringspring-mvctiles2spring-webflow-2

Spring Webflow | Different validate method per transition


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!!!


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.