There seems to be a related issue now that I am using the Preparable interface.
In some circumstances, I am using the "chain" result to keep the state through to the next action. In this case, the prepare method does not seem to be called. The action needs prepare to be called when it is executed directly for the situation you just helped me with, but when it is reached through chaining, those preparations are not done. To clarify: Action 'create' has a property 'locID' that needs to be prepared, because I need to extract loc.name and loc.value from the database based on the value of locID. This works fine when the create action is first called, and when the page is redisplayed due to validation errors. However, create has a button which takes me to a different page that generates the value of locID. In order to pass this value back to the create page, i've chained the return action to keep the locID value around. But when I return to the create page, prepare is not called, so I do not get the chance to reprepare with the new locID. So I would have to do the same actions in execute as I do in prepare, which would be redundant in in some cases, but necessary in others. Can you offer any suggestions? ----- Original Message ----- From: "larryreed" <larryr...@comcast.net> To: "Struts Users Mailing List" <user@struts.apache.org> Sent: Tuesday, November 17, 2009 12:12:57 PM GMT -08:00 US/Canada Pacific Subject: Re: Drop downs not populated after error Thanks, that's what I needed. Works great! ----- Original Message ----- From: "Oscar" <oscar.kalde...@gmail.com> To: "Struts Users Mailing List" <user@struts.apache.org> Sent: Tuesday, November 17, 2009 11:54:07 AM GMT -08:00 US/Canada Pacific Subject: Re: Drop downs not populated after error larryreed escribió: > I'm having a problem with the <s:select> in which the drop downs are > populated from a list of database objects. When I first display the screen, > the drop downs are properly populated. However, when there is an error in > some field, and the page is redisplayed, the drop downs are now empty. > > I've narrowed it down to an issue with the parameter validators. When a > property is annotated with a field validator (e.g. @EmailValidator) and that > field fails the validation, the form action execute is never called, so I do > not have the opportunity to initialize the data for the dropdowns. The page > is redisplayed with all the error messages as desired, but the dropdowns are > empty. > > If the fields pass all the annotated validators, the execute routine is > called, and if that routine then detects an additional error (e.g. user name > in use) and returns the INPUT status, then the dropdowns are properly > populated by the execute routine. > > How do I get around this problem? I'd like not to have to explicitly validate > everything in my actions. > > -- Larry > > Hi Larry Reed, you're right, the action never executes. To avoid that your action must implement the Preparable interface. Then you implement the method of the interface called prepare(). This method is used to initialize objects, like your List from the database. this method executes always, even if there's a validation error and your action method doesn't execute. prepare() does. With that, your list always be recreated in each server request even if you have validation errors or something like that. I hope it helps you. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org