struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alireza Fattahi <afatt...@yahoo.com.INVALID>
Subject Re: Struts 2 get custom action anotation in interceptors
Date Sat, 07 Jun 2014 04:57:23 GMT
Thanks!
A complete code sample at:

http://stackoverflow.com/questions/24021534/struts-2-get-custom-action-anotation-in-interceptors


 
~Regards,
~~Alireza Fattahi 


On Wednesday, 4 June 2014, 12:22, Lukasz Lenart <lukaszlenart@apache.org> wrote:
 


Take a look on com.opensymphony.xwork2.util.AnnotationUtils


2014-06-03 19:37 GMT+02:00 Alireza Fattahi <afattahi@yahoo.com.invalid>:
> Consider below action class with three action mappings. Two of them are annotated with
a custom annotation `@AjaxAction`
>
>     public class MyAction extends ActionSupport{
>
>       @Action("action1")
>       @AjaxAction  //My custom anotation
>       public String action1(){
>       }
>
>       @Action("action2")
>        public String action2(){
>         }
>
>       @Action("action3")
>       @AjaxAction  //My custom anotation
>       public String action3(){
>       }
>     }
>
>
> In an interceptor I want to access the `@AjaxAction` annotation. Is there any built in
support for this?!
>
> If not can I shall read the action name with `ActionContext.getContext().getName();`
and save a list of `ajaxAction` names in interceptor as an array and compare action name with
this array! any better way?!
>
>     private static final String[] AJAX_ACTIONS = new String[] {"action1", "action3"}
>
>     //in interceptor
>     String actionName = ActionContext.getContext().getName();
>     if (Arrays.asList(AJAX_ACTIONS).contains(actionName)) {
>                // do something
>             }
>
>
> ~Regards,
> ~~Alireza Fattahi

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message