Reputation: 7887
I have a class A :
class A extends ActionSupport{
int someId;
// getters/setters
public String execute(){
setSomeId(2);
return SUCCESS;
}
public String save(){
// something
}
}
In struts.xml
, I have configured an action "ViewId
" that takes us to the default method execute
, where someId
is set. Then, we are taken to a jsp page show.jsp
where I can access the someId
value. In show.jsp, I have to enter an email id and then submit the page. The action that's now called in "Save
" that takes us to the save method of the action class. But, I have given some checks in the corresponding validation.xml file A-Save-validation.xml
, which will check the email entered for a format. The problem is that if the xml validation fails, we are taken back to show.jsp, but the viewId parameter is now not available. Why is this so ?
The input page should appear similar to the user as before. Only the fields that are now validated should have an error page associated with them. Any workaround for this ?
Upvotes: 0
Views: 833
Reputation: 1057
Like @Umesh said, validation happens on the corresponding interecptor, before the action's method is called.
When validation fails, the action's method is never called and you will be taken to the INPUT result.
In order to achieve what you want you have some options:
1 is probably the easiest. I like option 3 as well.
Upvotes: 1