You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gunnar Hillert <gu...@hillert.com> on 2007/10/11 05:56:41 UTC

[S2] Configure Message Store Interceptor via Annotations

Hi,

Is there a way to configure the message store interceptor via annotations?

I started experimenting with the smarturls plugin for Struts 2
(http://code.google.com/p/smarturls-s2/) in order to get rid of my XML
configuration but noticed that I need the message store interceptor to have
success message to survive redirects. 

Well, it looks like the the message store interceptor does not have
annotations support (bummer). But maybe is there another way to solve this
issue? 

Thanks a lot!

Gunnar Hillert
-- 
View this message in context: http://www.nabble.com/-S2--Configure-Message-Store-Interceptor-via-Annotations-tf4604956.html#a13149004
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Configure Message Store Interceptor via Annotations

Posted by Gunnar Hillert <gu...@hillert.com>.
Hi Adam,

I have created a ticket in Jira:
https://issues.apache.org/struts/browse/WW-2252

and attached a first version with my changes to the interceptor. 

I was thinking of also adding functionality similar to your requirements. I
totally agree that it would be nice if Struts 2 handled the
storing/retrieving of messages automagically - However I am not sure if this
can be done easily (I ran into some issues when dealing with forwards
between 2 actions)

I think what certainly would work is something like an autoRetrieve mode.
That way I would have to use @StoreMessages, only. Maybe even better would
be to have a method:

addActionMessage(String aMessage, boolean storeToSession) ;

That way messages can be added selectively...and the circle closes and we
restored the functionality of Struts 1 :-)

Cheers,

Gunnar



Adam Hardy-3 wrote:
> 
> Hi Gunnar
> 
> I wanted it to work without needing to tell it when to do its stuff.
> 
> I based my changes on the requirement for displaying success messages
> after a 
> redirect.
> 
> The messages / errors only need to survive until the next request. So
> anything 
> in the request I put into the session (in the after method) and in the
> before 
> method, anything in the session, I remove and put into the request. Just
> like 
> you say, works like a charm.
> 
> Adam
> 
> Gunnar Hillert on 12/10/07 05:15, wrote:
>> Hi Adam,
>> 
>> Thanks for your comments. Yes, I looked at the sources for the
>> MessageStoreInterceptor and indeed it looks quite simple. I played around
>> with it tonight and I made the inteceptor annotations-aware. 
>> 
>> I have added 2 method-level annotations: @StoreMessages and
>> @RetrieveMessages
>> This works like a charm :-)  This will work for me as a start. I still
>> need
>> to clean it up a bit....and can then  send you what I have. 
>> 
>> What changes did you you?
>> 
>> Regards,
>> 
>> Gunnar
>> 
>> 
>> Adam Hardy-3 wrote:
>>> Gunnar,
>>>
>>> the message store interceptor is quite lean. I have copied it and
>>> written
>>> my own 
>>> version to give me the functionality I needed. Now with your comments,
>>> it
>>> seems 
>>> like a prime target for further development by S2 to beef it up a bit to
>>> provide 
>>> more options.
>>>
>>> Maybe we could put in a patch with both our changes, if you implemented
>>> what you 
>>> need?
>>>
>>> Regards
>>> Adam
>>>
>>>
>>>
>>> Gunnar Hillert on 11/10/07 04:56, wrote:
>>>> Hi,
>>>>
>>>> Is there a way to configure the message store interceptor via
>>>> annotations?
>>>>
>>>> I started experimenting with the smarturls plugin for Struts 2
>>>> (http://code.google.com/p/smarturls-s2/) in order to get rid of my XML
>>>> configuration but noticed that I need the message store interceptor to
>>>> have
>>>> success message to survive redirects. 
>>>>
>>>> Well, it looks like the the message store interceptor does not have
>>>> annotations support (bummer). But maybe is there another way to solve
>>>> this
>>>> issue? 
>>>>
>>>> Thanks a lot!
>>>>
>>>> Gunnar Hillert
>>>
>>> ---------------------------------------------------------------------
>>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Configure-Message-Store-Interceptor-via-Annotations-tf4604956.html#a13195995
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Configure Message Store Interceptor via Annotations

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi Gunnar

I wanted it to work without needing to tell it when to do its stuff.

I based my changes on the requirement for displaying success messages after a 
redirect.

The messages / errors only need to survive until the next request. So anything 
in the request I put into the session (in the after method) and in the before 
method, anything in the session, I remove and put into the request. Just like 
you say, works like a charm.

Adam

Gunnar Hillert on 12/10/07 05:15, wrote:
> Hi Adam,
> 
> Thanks for your comments. Yes, I looked at the sources for the
> MessageStoreInterceptor and indeed it looks quite simple. I played around
> with it tonight and I made the inteceptor annotations-aware. 
> 
> I have added 2 method-level annotations: @StoreMessages and
> @RetrieveMessages
> This works like a charm :-)  This will work for me as a start. I still need
> to clean it up a bit....and can then  send you what I have. 
> 
> What changes did you you?
> 
> Regards,
> 
> Gunnar
> 
> 
> Adam Hardy-3 wrote:
>> Gunnar,
>>
>> the message store interceptor is quite lean. I have copied it and written
>> my own 
>> version to give me the functionality I needed. Now with your comments, it
>> seems 
>> like a prime target for further development by S2 to beef it up a bit to
>> provide 
>> more options.
>>
>> Maybe we could put in a patch with both our changes, if you implemented
>> what you 
>> need?
>>
>> Regards
>> Adam
>>
>>
>>
>> Gunnar Hillert on 11/10/07 04:56, wrote:
>>> Hi,
>>>
>>> Is there a way to configure the message store interceptor via
>>> annotations?
>>>
>>> I started experimenting with the smarturls plugin for Struts 2
>>> (http://code.google.com/p/smarturls-s2/) in order to get rid of my XML
>>> configuration but noticed that I need the message store interceptor to
>>> have
>>> success message to survive redirects. 
>>>
>>> Well, it looks like the the message store interceptor does not have
>>> annotations support (bummer). But maybe is there another way to solve
>>> this
>>> issue? 
>>>
>>> Thanks a lot!
>>>
>>> Gunnar Hillert
>>
>> ---------------------------------------------------------------------
>> 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: [S2] Configure Message Store Interceptor via Annotations

Posted by Gunnar Hillert <gu...@hillert.com>.
Hi Adam,

Thanks for your comments. Yes, I looked at the sources for the
MessageStoreInterceptor and indeed it looks quite simple. I played around
with it tonight and I made the inteceptor annotations-aware. 

I have added 2 method-level annotations: @StoreMessages and
@RetrieveMessages
This works like a charm :-)  This will work for me as a start. I still need
to clean it up a bit....and can then  send you what I have. 

What changes did you you?

Regards,

Gunnar


Adam Hardy-3 wrote:
> 
> Gunnar,
> 
> the message store interceptor is quite lean. I have copied it and written
> my own 
> version to give me the functionality I needed. Now with your comments, it
> seems 
> like a prime target for further development by S2 to beef it up a bit to
> provide 
> more options.
> 
> Maybe we could put in a patch with both our changes, if you implemented
> what you 
> need?
> 
> Regards
> Adam
> 
> 
> 
> Gunnar Hillert on 11/10/07 04:56, wrote:
>> Hi,
>> 
>> Is there a way to configure the message store interceptor via
>> annotations?
>> 
>> I started experimenting with the smarturls plugin for Struts 2
>> (http://code.google.com/p/smarturls-s2/) in order to get rid of my XML
>> configuration but noticed that I need the message store interceptor to
>> have
>> success message to survive redirects. 
>> 
>> Well, it looks like the the message store interceptor does not have
>> annotations support (bummer). But maybe is there another way to solve
>> this
>> issue? 
>> 
>> Thanks a lot!
>> 
>> Gunnar Hillert
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Configure-Message-Store-Interceptor-via-Annotations-tf4604956.html#a13168920
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Configure Message Store Interceptor via Annotations

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Gunnar,

the message store interceptor is quite lean. I have copied it and written my own 
version to give me the functionality I needed. Now with your comments, it seems 
like a prime target for further development by S2 to beef it up a bit to provide 
more options.

Maybe we could put in a patch with both our changes, if you implemented what you 
need?

Regards
Adam



Gunnar Hillert on 11/10/07 04:56, wrote:
> Hi,
> 
> Is there a way to configure the message store interceptor via annotations?
> 
> I started experimenting with the smarturls plugin for Struts 2
> (http://code.google.com/p/smarturls-s2/) in order to get rid of my XML
> configuration but noticed that I need the message store interceptor to have
> success message to survive redirects. 
> 
> Well, it looks like the the message store interceptor does not have
> annotations support (bummer). But maybe is there another way to solve this
> issue? 
> 
> Thanks a lot!
> 
> Gunnar Hillert


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