You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Oscar <os...@gmail.com> on 2009/11/16 21:34:58 UTC
Question about PrepareInterceptor and Preparable
Hi to all. I'm developing a Struts 2 application and i create an
interceptor to initialize values and to validate user login. I want to
load a list to jsp to populate a s:select so i implemented the
Preparable interface in my action, and the method prepare(), so i type
the code in this method to get the list from DB. For that i supposed
that my custom interceptor will execute before the prepare method
because in my interceptor i initialize my connection that i use on
prepare(), but perpare() executes before that, so it gives me a
NullPointerException.
Then i googled about it and i found something about PrepareInterceptor,
so i defined in my interceptor stack after my own interceptor, like this:
<interceptor-stack name="appInteceptors">
<interceptor-ref name="initializeInterceptor" />
<interceptor-ref name="prepare" />
<!--<interceptor-ref name="permissionsInterceptor" />-->
<interceptor-ref name="defaultStack" />
</interceptor-stack>
But it doesn't work, because i tought that with the order change my
interceptor will execute before than action's prepare() method, but don't.
Somebody knows how to execute prepare() after a custom interceptor
execution?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Question about PrepareInterceptor and Preparable
Posted by Oscar <os...@gmail.com>.
Chris Pratt escribió:
> Did you either set your appInterceptors stack to be the default stack, or
> define the actions you're testing with to use the appInterceptors stack
> explicitly? Otherwise, you're actually just using the defaultStack.
> (*Chris*)
>
> On Mon, Nov 16, 2009 at 12:34 PM, Oscar <os...@gmail.com> wrote:
>
>
>> Hi to all. I'm developing a Struts 2 application and i create an
>> interceptor to initialize values and to validate user login. I want to load
>> a list to jsp to populate a s:select so i implemented the Preparable
>> interface in my action, and the method prepare(), so i type the code in this
>> method to get the list from DB. For that i supposed that my custom
>> interceptor will execute before the prepare method because in my interceptor
>> i initialize my connection that i use on prepare(), but perpare() executes
>> before that, so it gives me a NullPointerException.
>>
>> Then i googled about it and i found something about PrepareInterceptor, so
>> i defined in my interceptor stack after my own interceptor, like this:
>>
>> <interceptor-stack name="appInteceptors">
>> <interceptor-ref name="initializeInterceptor" />
>> <interceptor-ref name="prepare" />
>> <!--<interceptor-ref name="permissionsInterceptor" />-->
>> <interceptor-ref name="defaultStack" />
>> </interceptor-stack>
>>
>> But it doesn't work, because i tought that with the order change my
>> interceptor will execute before than action's prepare() method, but don't.
>>
>> Somebody knows how to execute prepare() after a custom interceptor
>> execution?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> Well Chris, you're right, i didn't realize that i don't specified my action to use that interceptor stack, i've been specified a default stack for all the package but in some moment i deleted it and i don't see that
Thanks and sorry for that.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Question about PrepareInterceptor and Preparable
Posted by Chris Pratt <th...@gmail.com>.
Did you either set your appInterceptors stack to be the default stack, or
define the actions you're testing with to use the appInterceptors stack
explicitly? Otherwise, you're actually just using the defaultStack.
(*Chris*)
On Mon, Nov 16, 2009 at 12:34 PM, Oscar <os...@gmail.com> wrote:
> Hi to all. I'm developing a Struts 2 application and i create an
> interceptor to initialize values and to validate user login. I want to load
> a list to jsp to populate a s:select so i implemented the Preparable
> interface in my action, and the method prepare(), so i type the code in this
> method to get the list from DB. For that i supposed that my custom
> interceptor will execute before the prepare method because in my interceptor
> i initialize my connection that i use on prepare(), but perpare() executes
> before that, so it gives me a NullPointerException.
>
> Then i googled about it and i found something about PrepareInterceptor, so
> i defined in my interceptor stack after my own interceptor, like this:
>
> <interceptor-stack name="appInteceptors">
> <interceptor-ref name="initializeInterceptor" />
> <interceptor-ref name="prepare" />
> <!--<interceptor-ref name="permissionsInterceptor" />-->
> <interceptor-ref name="defaultStack" />
> </interceptor-stack>
>
> But it doesn't work, because i tought that with the order change my
> interceptor will execute before than action's prepare() method, but don't.
>
> Somebody knows how to execute prepare() after a custom interceptor
> execution?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>