Without knowing what are you actually trying to accomplish with this interceptor, I would warn that when an interceptor messes up with the parameters, you need to carefully think where in the interceptor chain this interceptor will execute.
2008/7/11 Andreas Mähler <[EMAIL PROTECTED]>: > Hello Gabriel, > > yes, I indeed took that into consideration, but if i am not wrong, there are > two drawbacks: > > 1: When I create my own base class, and would like to use the prepare-method > for something else, too, I need to overwrite the old method and mustn't > forget to call super.prepare() in my implementation. IMO, this is a likely > source of bugs. > > 2: I would have had to mess with the defaultStack anyway, since prepare is > located before some other important interceptors (e.g. i18n) so I would have > lost this functionality by taking an "early shortcut". > > The Interceptor was done in 10mins and as far as i could test it, it seems > to work fine. > > public class SubmitInterceptor implements Interceptor > { > public static final String INPUT = "input"; > > public void destroy() {} > public void init() {} > > > private String paramNames; > > public void setParamNames( String paramNames ) > { > this.paramNames = paramNames; > } > > > public String intercept( ActionInvocation ai ) throws Exception > { > Map params = ai.getInvocationContext().getParameters(); > > String[] paramNames = this.paramNames.split( "," ); > > for( String param : paramNames ) > { > if( params.get( param.trim() ) != null ) > return ai.invoke(); > } > > return INPUT; > } > } > > I created a new interceptor stack for my webapp that is like defaultStack, > but with the SubmitInterceptor inserted right before conversionError: > > <interceptor-ref name="submit"> > <param name="paramNames">submit</param> > </interceptor-ref> > > As for the view, i am currently setting the "submit" parameter (as > configured to be looked for above) for the Button: > > <s:submit name="submit" label="OK" value="true" type="button" /> > > Comments and suggestions are welcome :-) > > ~Andreas > > > > Gabriel Belingueres schrieb: >> >> You can also opt for sharing the prepare() code through inheritance, >> meaning that you create a superclass action holding the prepare() >> code, instead of coding a custom interceptor. >> >> 2008/7/11 Andreas Mähler <[EMAIL PROTECTED]>: >>> >>> Thanks for your Answer, Lukasz. >>> >>> I already know the PrepareInterceptor and it can be used for what I would >>> like to do. But I consider a special interceptor more convinient, since I >>> intend to use it for more than one pair of view and action. (Using >>> PrepareInterceptor would imply the need to add the code to every single >>> action.) > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]