This topic seems to keep coming up, and with no real good solutions
(IMHO). One point that seems to be made frequently though, is that the
logic to repopulate the lists really doesn't belong in the ActionForm,
yet that seems to be the most convenient place to put it. I know I would
really like this logic to go in the Action. My solution currently
consists of setting validate to false in struts-config.xml, and
validating manually in my action:

ActionErrors errors = myForm.validate();
if (hasErrors(errors)) {
  populateLists();
  saveErrors(errors);
  return getInputForward(mapping);
}

Although I don't particularly like this approach either, it's the one I
like the best (so far).

One idea I had (and tried to implement) was to put a callback in the
Action that was invoked after validation failure, but before forwarding
to the input view? What do others think of this approach? What other
solutions are there?

Joe

> -----Original Message-----
> From: Rick Reumann [mailto:[EMAIL PROTECTED]] 
> Sent: Monday, February 10, 2003 3:58 AM
> To: Struts Users Mailing List
> Subject: Where to repopulate dynamic lists ?
> 
> 
> Sorry to repost this question but it still has me wondering...
> 
> 
> Say you have a form where a user is to select "An Order To 
> Update" from an options list. Now also assume that these 
> orders to choose from change very frequently. You also will 
> need to validate the form when it's submitted.
> 
> * Where is it best to repopulate this type of dynamic list 
> (example above: 'orders')? The list of orders that make up 
> the options list needs to be repopulated somewhere in case 
> validation returns false and returns the user to the form 
> page again.  
> 
> It seems like you have 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 
> maybe even directly into FormBean).
> 
> 2) Use session scope so the list is available at all times 
> until repopulated by some setUp type of action.
> 
> 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.
> 
> 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.
> 
> Curious what other's thoughts are on this situation.
> 
> Thanks,
> 
> -- 
> Rick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 



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

Reply via email to