Hi All, I am working on struts2. I have two fields in my action-validation.xml. I want if validation get fails at first field it will go to some jsp page (say a.jsp) and if validation get fails at second field then it will go to another jsp (say b.jsp). As it always return "input" when validation fails so currently I can target only one jsp page against it. Please provide solution if possible? Thanks in advance.
views:
794answers:
5
A:
You will need to create custom validation method in your action, return a custom resut:
public void validate() {
if(!isFieldAValid()) {
return "DISPLAY_A";
}
if(!isFieldBValid()){
return "DISPLAY_B";
}
}
Then in your struts.xml you will need to add the custom results:
<result name="DISPLAY_A">/a.jsp</result>
<result name="DISPLAY_B">/b.jsp</result>
Rich Kroll
2009-05-06 15:25:27