struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <>
Subject Re: advice- session vs request scope for Action Form
Date Thu, 13 Jun 2002 21:02:15 GMT
Generally, the reset() on an ActionForm should only be used on
checkboxes or things that really need to be reset. Many of us have been
using it reset things to their defaults, but in practice, there seems to
be no point to that, outside of the checkbox issue. 

So, go ahead and use a session-scope bean if that's what you need. 

If the DynaActionForm reset is getting in your way, then subclass it,
and make it do what ~you~ want. After all, this is still OOP. =:0) We
are ~suppose~ to subclass methods that don't work the way we want them
to. That's the ~beauty~ of OOP. 

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web:

Rick Reumann wrote:
> It seems as though the majority of times your ActionForms should use
> request scope, but what about situations where you might grab data
> from one jsp form and then need to use the information you got from
> that page during other parts of your application. Here's the actual
> situation...
> 1) user has to select a "userType" from some select options.
> 2) once this "userType" is selected I need to use this property in
> some DispatchAction methods and as a display on some other pages as
> the user traverses the application. (the "userType" can change if he/she
> goes back to the original form and selects a new one).
> Now the question is where should the "userType" field be stored so I
> have access to it in other parts of the user's session? I first
> thought it would be best stored as a field in my ActionForm with
> session scope so that other pages and Actions could have access to it,
> but if reset() is always called regardless of the scope it seems to
> imply that the ActionForms shouldn't really be used in Sesion scope?
> (Even though the default reset behavior wouldn't reset my field upon
> each request unless I provide implementation, it seems to imply that I
> should provide the implementation, and definitely as Chuck pointed out
> to me, in the case of DynaActionForms, the reset will truly reset the
> fields to default values, which means if I use a DynaActionForm and
> want it in Session scope I have to override the reset() method and
> make sure it doesn't touch the fields I want to keep in the session.
> That sort of seems ugly to me.)
> Am I better off just sticking the "userType" variable itself into the
> session after I get it from the Form? Or maybe just put it into
> the DTO (that I eventually convert the ActionForm into anyway) and
> then stick that DTO in the session?
> Thanks for any comments.
> --
> Rick
> "Any man, in the right situation, is capable of murder. But not any
> man is capable of being a good camper. So, murder and camping are not
> as similar as you might think."
>   -Jack Handey
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message