You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mansour <ma...@yahoo.com> on 2007/04/16 03:02:55 UTC

intercept return, and Interceptor implementing ServletRequestAware

I can not figure out how to configure an interceptor. What does the 
returned string represents ? I mean if I have an action that has one or 
more interceptors, how would the returned string of the interceptor 
affects the execution of this action ?

Any examples ?



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: intercept return, and Interceptor implementing ServletRequestAware

Posted by Mansour <ma...@yahoo.com>.
Dave Newton wrote:
> --- Mansour <ma...@yahoo.com> wrote:
>   
>> What's the point then of having an action, if the
>> intercept method is going to execute the action. Why
>>     
>
>   
>> don't I just put the action code in an interceptor ?
>>     
>
> Because interceptors are normally called for *groups*
> of actions, not just one... just like it says in the
> first couple of paragraphs at the top of:
>
> http://struts.apache.org/2.x/docs/interceptors.html
>
> For instance, "validation" is a cross-cutting concern.
> So it makes sense to move it away from the code that
> decides what to to with the validated data.
>
>   
GOTCHA, so if I have a common method in all the action and I need to 
execute some code that is generic to all of them, then makes scenes to 
put in an interceptor. coooooool.

Ok, another question. If I have an custom interceptor does this sop 
another interceptor from execution. For example, I have this code:

    public String intercept(ActionInvocation invocation) throws Exception {
        AccountAction action = (AccountAction)invocation.getAction();
        return action.execute();
    }

shouldn't the interceptor that's responsible for setting the values on 
the action, gets executed too ?
in my case it's not. Why? here' my config:

<action name="accountAction"  class="billing.AccountAction" >
          <interceptor-ref name="prepareAccount"></interceptor-ref>
            <result name="SUCCESS">/pages/accountView.jsp</result>
             <result name="ERROR">/pages/exception.jsp</result>
             <result name="input">/pages/accountView.jsp</result>
        </action>



> Of course you *could* put all your action code into an
> interceptor and define an interceptor stack for every
> action-that-no-longer-had-an-action. There are many
> ways to make things harder--don't get me wrong, I
> applaud your efforts to find them.
>   

I am trying to make things easier :P but definitely always interested in 
finding a harder way :P
> You could put all your action code into filters, then
> you wouldn't even need servlets. Or put everything
> inside a JSP, then you wouldn't even need to compile
> or worry about whether or not your container
> hot-deploys.
>   
This will be a great idea. But then I will never be using struts. You 
know, it has to be used in a away or another. Someone must use it. It's 
unfair for the opensource community to write softwares and no one uses 
them. :P lol

> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: intercept return, and Interceptor implementing ServletRequestAware

Posted by Dave Newton <ne...@yahoo.com>.
--- Mansour <ma...@yahoo.com> wrote:
> What's the point then of having an action, if the
> intercept method is going to execute the action. Why

> don't I just put the action code in an interceptor ?

Because interceptors are normally called for *groups*
of actions, not just one... just like it says in the
first couple of paragraphs at the top of:

http://struts.apache.org/2.x/docs/interceptors.html

For instance, "validation" is a cross-cutting concern.
So it makes sense to move it away from the code that
decides what to to with the validated data.

Of course you *could* put all your action code into an
interceptor and define an interceptor stack for every
action-that-no-longer-had-an-action. There are many
ways to make things harder--don't get me wrong, I
applaud your efforts to find them.

You could put all your action code into filters, then
you wouldn't even need servlets. Or put everything
inside a JSP, then you wouldn't even need to compile
or worry about whether or not your container
hot-deploys.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: intercept return, and Interceptor implementing ServletRequestAware

Posted by Mansour <ma...@yahoo.com>.
Musachy Barroso wrote:
> http://struts.apache.org/2.x/docs/interceptors.html
>
> http://struts.apache.org/2.x/docs/writing-interceptors.html
>

What 's the point then of having an action, if the intercept method is 
going to execute the action. Why don't I just put the action code in an 
interceptor ?




>
> On 4/15/07, Mansour <ma...@yahoo.com> wrote:
>>
>> I can not figure out how to configure an interceptor. What does the
>> returned string represents ? I mean if I have an action that has one or
>> more interceptors, how would the returned string of the interceptor
>> affects the execution of this action ?
>>
>> Any examples ?
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: intercept return, and Interceptor implementing ServletRequestAware

Posted by Musachy Barroso <mu...@gmail.com>.
http://struts.apache.org/2.x/docs/interceptors.html

http://struts.apache.org/2.x/docs/writing-interceptors.html


On 4/15/07, Mansour <ma...@yahoo.com> wrote:
>
> I can not figure out how to configure an interceptor. What does the
> returned string represents ? I mean if I have an action that has one or
> more interceptors, how would the returned string of the interceptor
> affects the execution of this action ?
>
> Any examples ?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd