• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session object or population methods in ActionForm??

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering if anyone had any suggestions. I have a validate method in my ActionForm that checks user input from the jsp. The jsp has several selects that need to be repopulated with 300+ elements. Should I store the ArrayLists in the session or, write methods that hit the DB and repopulate the fields from the ActionForm (yuck)? Any solutions/suggestions ?
thanks
A.T.
 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It depends on how variable the information is.
If the dropdowns are the same information and simply repeated row after row, I'd read in the Action and save in request.
As a general rule, Form beans should not be hitting the DB or populating anything. All that work should be done in the Action.
Form beans should do nothing but pass information to the JSP and validate what was posted, that's it.
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On my last project I developed a framework to manage all the dropdown lists needed, so when programming a new page, all I would have to do is write the DB call in my factory bean, and write one function call in the action for each dropdown list required.
One of the parameters specified in the action was REQUEST, SESSION or APPLICATION. Dropdown lists that never changed from user to user or day to day were saved in the APPLICATION scope. Lists that never changed for the user were saved in SESSION scope, and lists that were data-dependent were saved in REQUEST scope.
The action's call to create the dropdown lists was the first thing the action did, so that any errors would not cause their creation to be skipped.
There was a fourth type of list that was even more dynamic - lists dependent on calculated data. These could not be done first, and of course were stored in the REQUEST scope.
HTH,
Adam
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you use a JSTL custom tag to render your drop down lists.
Create a cache of application level values and make them available from a Boot Strap servlet. Make your cache a follow the standard key-value pattern where you pass in a key to the cache to receive a value out of it.
Next, build a JSTL tag that has access to the cache provided by the BootStrap servlet.
Have the definition of the JSTL tag take an input for a key that you could hard code into your jsp pages, when that is relevant.
For example, your tag could look like...
<custom:value key="123abc" />
When you need the drop down to render dynamically, add another argument to your jstl tag to look for a viewbean, and method on the view bean to get the tag key.
<custom:value name="" property=""/>
Where 'name' is the key to access some object in pageContext, and 'property' is the method to use on 'name'. Using reflection you could call 'property' on 'name'.
Example
<custom:value name="formBean" property="foo.bar" />
It is assumed that there is a getFoo() method on the object returned by pageContext.getAttribute(formBean), and a getBar() on the result of getFoo().
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic