You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dorothy Rifai <dr...@rcn.com> on 2004/09/04 14:32:58 UTC

issue - default value

I have drop-down lists for the month, day, and year. I want to set the
"selected"  value in each box to the value for the current date. I tried
to use the html:options custom tag, but couldn't figure out how to set a
default value. So I wrote a jsp scriptlet to provide the functionality.
Now I am adding error handling. When there is an error, the jsp page
redraws with the ActionError at the proper place on the page. The
drop-down list which my scriptlet created is not there. 
 
I would prefer to use a custom tag, but can't find an example which
handles a "selected" value. If I have to stick with the scriptlet, what
should I do within my ActionForm so the drop-downs will appear when the
page is redrawn after an error.
 
Thanks in advance for the help.
 
Dorothy

Re: issue - default value

Posted by Rick Reumann <st...@reumann.net>.
Dorothy Rifai wrote:

> I have drop-down lists for the month, day, and year. I want to set the
> "selected"  value in each box to the value for the current date. I tried
> to use the html:options custom tag, but couldn't figure out how to set a
> default value.  

Just make sure the ActionForm select property is set before you get to 
your form and that'll be your default value. For example..

<html:select property="fooBar">

Before you get to this form you should always go through an Action and 
you could make sure 'fooBar' is set to something there or just make sure 
you give "fooBar" a default value in your ActionForm.

If "fooBar" matches one of the options it will be selected.


-- 
Rick

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