You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anna Kerekes <An...@onx.com> on 2004/10/01 20:28:49 UTC

populate html:select

Hello,
 
I am using struts validation to validate an input form.  In my jsp I have:
 
<html:select property="effectiveDay">

<option value="1" selected>1

<option value="2">2

<option value="3">3

<option value="4">4

</html:select>

The form is filled out.  After I hit the "submit" button Struts validation is run and the input form is displayed again with the errors on the form.  The problem is that the value selected from the drop-down menu (i.e. html:select) before the "submit" button was hit is NOT preserved on the form with the validation errors.  So the user has to re-enter whatever value he/she entered before validation.  This is annoying......is there a way I can make it so that the hmtl:select could be populated with the value that was entered before (if any).  I suspect that this value is stored somewhere (in request scope?) but I'm not sure how to get it.....

What is strange is that other fields on my input form are preseved (i.e. textboxes, and textareas) but not drop-down menus, checkboxes, and file.

any help appreciated,

Anna:)

 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: populate html:select

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Anna Kerekes" <An...@onx.com>
Hello,
<html:select property="effectiveDay">
<option value="1" selected>1
...
> The problem is that the value selected from the drop-down menu (i.e.
html:select)
> before the "submit" button was hit is NOT preserved on the form

You need to use Struts tags for the options if you expect the framework to
pre-fill the form.  Take a look at <html:option> and <html:options> which
you can use with various attributes including creating the lists from a
Collection.

-- 
Wendy Smoak


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org