You could implement Preparable and load countryOptions in the prepare() method.
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/Preparable.html Zarar On 8/20/07, Boon Leng <[EMAIL PROTECTED]> wrote: > > In my form, I have a select box which get the option value populated from > database. > But when validation fail and return to input page (jsp page), I get the > error where the option value cannot be found. > > I know this is because the method (e.g search) is not called to retrieve > data from database. I tried to use "chain" result type to forward back to > the main action (e.g list) but I get "Infinite recursion detected" error. > May I know what is the best way to return to input page and at the sametime > retrieve data for the select box? > > I don't want to store the option value in http session coz this way I need > to find a way to clean up unuse option value and might get problem is user > spore multiple tab on browser. > > Appreciate is someone can give some guidelines. Thanks. > > > The following is my config and code. > struts.xml > ----------------- > <action name="*_search" class="{1}Action" method="list"> > <result name="success">/pages/{1}_search.jsp</result> > <result name="input">/pages/{1}_search.jsp</result> > <result name="cancel" type="redirect">welcome.html</result> > </action> > > Sample_search.jsp > ----------------- > <s:form> > <s:select name="user.country" > label="%{getText('user.country')}" > list="countryOptions" > headerKey="-1" > headerValue="%{getText('messages.select')}"/> > > <s:submit key="buttons.search" method="search" theme="simple"/> > <s:submit key="buttons.cancel" method="cancel" theme="simple"/> > </s:form> > > SampleAction > ----------------- > public class SampleAction extends ActionSupport { > .... > > @SkipValidation > public String list() throws Exception { > this.countryOptions = lookupManager.getCountries(); > return SUCCESS; > } > > public String search() throws Exception { > List<?> results = userManager.findByValueBean(user); > this.listHolder = new PagedListHolder(results); > > return SUCCESS; > } > > .... > } > -- > View this message in context: > http://www.nabble.com/Reload-combo-option-if-validation-fail.-tf4297263.html#a12231644 > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > 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]