struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mech" <>
Subject RE: What is the best practice for reseting dynamic lists?
Date Sat, 08 Feb 2003 15:18:25 GMT
I had a similar question recently. Maybe I asked too "complex" or
unclear so i didn't get an answer yet. But I tried to find an answer

> -----Original Message-----
> From: Rick Reumann [] 
> Sent: Samstag, 8. Februar 2003 11:30
> To: Struts Users Mailing List
> Subject: What is the best practice for reseting dynamic lists?
> As a hypothetical, say you have a form where a user is to 
> select "favorite song." Now also assume that the songs to 
> choose from change very frequently. You also want to validate 
> the form.
> Where is it best to repopulate this type of dynamic list 
> which is necessary so that the list will show up again if 
> validation is false?
> It seems like you three choices:
> 1) In the reset method repopulate the list by making a call 
> to business layer to get back your list and put in scope (or 
> in formBean).
That's the way I do it usually. I put it into request scope and get
"new" data from db.
> 2) Use session scope so the list is available at all times 
> until repopulated by some setUp type of action.
I was thinking about this, too. But considered it to be a bad idea,
because usually i have so much data from db that it wouldn't be wise to
store it in the session scope. Would consume to much memory, i guess.
But depends on the amount of data you need.
> 3) Possibly set this list in application scope upon container 
> start up and maybe have a thread running that periodically 
> updates the list and put the new list back into application scope.
If you really don't update frequently. It might work. I'm considering
this with one xml-file which contains my web structure and is used by
every jsp to built up the navigation links. During development i have
this bean in request scope, but plan to put it in app scope later and
allow some kind of manual update if someone does a change to the web
> Are there any other options available? I happen to like #1 
> the best but I'm wondering what others think. I don't really 
> like option 2 as it requires a form to be put into session 
> scope that really doesn't need to be there (apart from the 
> re-population of lists). Also a pain to monitor cleaning the 
> form out of session when it is no longer needed. Option 3 
> would be ok if the information in the list rarely changed, 
> but if it's data that changes very frequently I wouldn't want 
> to rely on some time interval to have to go by before getting 
> fresh data.
I have a similar problem, because I need a session scope "cart" bean to
put items in. Of course, I need some data from db to for prepopulating
the form for my views. Actually I doubt that it's a good idea to put
everything into session scope because of the amount of data. I just need
ONE session persistent arraylist for the cart and the rest can be
request scope. 
Unfortunately Struts says "one action mapping = one action form"... So I
have no chance to use one session cart bean + one request db-populated

The only idea I had so far was splitting up the actions into one "fill
cart" action which is filling the "cart" and using a session bean form
to store it and a second "show cart" action which grabs this "cart"
session bean from the SessionContext manually with servlet functionality
and uses a request scoped form for populating the view.

Until now I've not yet finished grabbing this session cart bean from a
second action, but I believe it must work.
> Curious what other's thoughts are on this situation.
Also curious to find out, if that's a good idea, or if there are better
> Thanks,
> -- 
> Rick
Thx, too.
One thing I found out, was not the reset() the cart bean arraylist to
null, if you use session scope ;-)

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

View raw message