This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am needing to load collections for my html:selects in a form. The problem I am having is when and where to load this collections from the database in order to keep that code out of my JSP. Just an FYI - I am using the DynaValidatorForm instead of hand coding an ActionForm class if this makes any difference, because I have read in a couple of places that this is where you should do this, but that doesn't make sense to me. My other thought was to load them as a Bean after you log in, but that would require me putting these in the Session and I don't really want/need them in the session object. Thanks.
The approach we have used on our projects is to load frequently/commonly used options lists (e.g. list of US States) into the application context. This is done at startup. Less frequently used options lists are put in the request context. This is done before the action forwards to the JSP. I don't know much about the DynaActionForm as I've been working with 1.0.x but from what I've read about it, I wouldn't think you'd want to put the collection there even if you could. Besides, the Struts select tag documentation is probably one of the most confusing of the lot and I've found it much easier to use when the options list has been placed in one of the context collections; YMMV.