I was thinking about adding a new Interface (like validationAware, etc.) for sturts 2. The methods of the interface would be methods that sets specific parameters that has to be present inside the request.
For example, consider this Interface :
public interface MyCustomInterfaceForActions {
/**
* Set a specific parameter into the request
*/
public void setMyParameter1InRequest(HttpServletRequest request, String myParameter);
/**
* Sets another specific parameter into the request
*/
public void setSecondParamInRequest(HttpServletRequest request, String myParameter);
}
The thing is that I don’t want to have to “call” the method “setParameterInRequest” in “execute” methods of each actions that implements that interface.
Also, I want to “force” the actions to set specific parameters into the request.
Is there a way to do that without having to call the “set” methods inside all “executes” methods of my actions? For example, can I extend a struts’ “actionExecutor” (I made that name up) and change it’s behavior to check if the class implements “MyCustomInterfaceForActions” and call the “set” methods if it’s the case?
Or better yet, just check to see if the interface is implemented and just add those parameters to the request anyway, without having to implement methods?
Why not simply use the Preparable, interface. This way you can do your initialization in the prepare() method?