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 

Reply via email to