struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexis Pigeon" <pigeon.ale...@gmail.com>
Subject Re: [S2] How to keep a reference to a bean without using a session scope?
Date Wed, 11 Apr 2007 06:21:25 GMT
Hi Mark,

On 10/04/07, Mark Menard <mark@mjm.net> wrote:
> There's a cleaner Struts 2 way of doing this. Take a look at the
> org.apache.struts2.interceptor.SessionAware interface. This will make your
> action independent of the servlet spec and more easily testable.

Thanks for the tip!

> > This works perfectly as expected, as long as there is only one
> > instance of the application launched at a time in the same browser
> > (using Firefox or IE7 tabs for example). In that case, the bean is
> > shared between the different instances, which is problematic since its
> > content depends on previous data input.
>
> You need a conversation scope. There is no direct support for this in the
> Servlet spec, nor in Struts 2 directly. You could take a look at using the
> Spring Webflow integration (I don't know the link). You could also take a
> look at a simple interceptor I created for this purpose.
> (http://www.vitarara.org/cms/node/84) I have since updated that method to
> simply be an extension of ModelDriven, if you're interested in the most
> recent version let me know.

The concept of conversation scope is exactly what I was looking for.
The most common situation where I would need it is when having a
select input which content depends on the item chosen from another one
(for example, a set of two selects representing countries and cities,
the content of the latter representing the cities of the chosen
country only).
In my case, the generation of the "subselect" can be quite
time-consuming, thus the need to keep it in some higher scope than the
request.
As for the Interceptor you wrote, I would be most interested in the
most recent version.

Thanks for the help,
alexis

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


Mime
View raw message