Hi,

so far I only use request scoped form beans. Mainly not for user input fields, but for 
storing database information that is needed to display my views. So I need to 
prepopulate my form beans almost always. Works fine.

But now I need a kind of "shopping cart bean". I remember that Struts allows to set 
session scope in the struts-config.xml but I'm not sure if this is a good solution in 
my case.

Let's say I want to fill that cart with some item ids. Later in my shopping basket i 
need grab this cart ids, query the database to prepopulate (another?) form bean with 
some more information about those items from the db.
This means, if I take only "one" form bean for the shopping cart which I'll also use 
for a second "show basket" action that will show all the items I have, I would store a 
lot of information in the session scope.
Actually it would be enough to store just those item ids in the session scope. On the 
other hand the struts docu recommends to use one form for several actions that somehow 
work on it. But I'm confused...

So that means I better take one cart bean form with just the ids and one form bean for 
the "show basket" action, or?

I mean, is it better to have something like:
addToCart.do + cartFormBean (in session scope)
showBasket.do + showBasketForm (in request scope)

But how to grab the cartFormBean in showBasket.do? I can only specify one form per 
action in struts-config.xml!?

Is there a Struts way to do this without putting too much data into session scope, or 
should i get the cartFormBean directly from the servlet's sessionContext while in 
showBasket.execute()?


One more question about the form bean's reset() method. In case my form bean is in 
session scope, when is reset() called? 
I know for request scope that reset() is called every time the form bean is used. But 
I guess for session scope this wouldn't make sense because I would "null" my shopping 
cart Arraylist every time...?!

Hope that's not to confusing for everybody as for me at the moment. Would be happy to 
get some ideas on how to handly "cart" in session scope with Struts.

Thx.
Michael





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to