views:

32

answers:

1

In Struts2 you can change the method used for execution for an action by changing the method attribute in the following line:

<action name="registerVal" class="cz.vutbr.fit.pishotel.model.action.Register" method="execute">

Is it possible to change the validation method used as well, or is the validate method name hardcoded.

A: 

It hard coded in the following way. If you have:

<action name="registerVal" class="cz.vutbr.fit.pishotel.model.action.Register" method="myMethod">

Then the validation interceptor will call

public void validateMyMethod() {

if (someValue == null) {

addFieldError("myField","myMessage");

}

}

If there are errors in the fieldErrors collection then INPUT will be returned for registerVal