Gianpiero Caretti wrote:
[EMAIL PROTECTED] wrote:
FYI, all of my Actions call a common setup function at the start of execute(),
and one of the things it does is set an attribute "command" in the request
with the value of getPath() called on the ActionMapping.
The only think I don't like with this solution is that the JSP writer has to know the existence of the "command" attribute into request. Moreover if the Action writer forgot to call the "setup" method the request attribute will not set.
You can use a custom RequestProcessor instead of a common Action method to make sure your Action writers don't forget to call the "setup" method. Another trick is to write a base Action class with a final execute method so Action writers can't skip steps:
public class MyBaseAction extends Action {
public final ActionForward execute(form, mapping, request, response) { initializeRequestAttributes(form, mapping, request, response); return realExecute(form, mapping, request, response); }
protected final void initializeRequestAttributes(form, mapping, request, response) {
request.setAttribute("command",mapping.getPath());
}
protected ActionForward realExecute(form,mapping,request,response) { // this method is what Action developers write } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]