You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Paradis, André" <an...@versalys.com> on 2001/09/19 18:05:45 UTC

html:select and "remembering" selection

Hi guys,

Here is a simple form:

<html:form action="/selectTest">
	<html:select property="currentSelection">
     		<html:options collection="aList" 
				  property="key" 
                          labelProperty="label"/>  
      </html:select>              
</html:form>

This works great for populating the list, but how do i specify that an
option should be selected? (the key of the selected option is in a bean)

What i want to do is proces the form, store the choosen key in a bean in
session scope so that every time the form is redisplayed, the previsouly
choosen key is marked as selected.

The form bean asssociated with this form is currently stored in request
scope.

Any inputs appreciated

Andre Paradis

Re: html:select and "remembering" selection

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Do you have a getCurrentSelection() method in your form bean?    and are you
saving it with a setCurrentSelection?

Have your Action class grab the selection from the session and call
setCurrentSelection before returning from the perform method.   That should
do the trick.

    Erik

----- Original Message -----
From: "Paradis, André" <an...@versalys.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, September 19, 2001 9:05 AM
Subject: html:select and "remembering" selection


Hi guys,

Here is a simple form:

<html:form action="/selectTest">
<html:select property="currentSelection">
     <html:options collection="aList"
  property="key"
                          labelProperty="label"/>
      </html:select>
</html:form>

This works great for populating the list, but how do i specify that an
option should be selected? (the key of the selected option is in a bean)

What i want to do is proces the form, store the choosen key in a bean in
session scope so that every time the form is redisplayed, the previsouly
choosen key is marked as selected.

The form bean asssociated with this form is currently stored in request
scope.

Any inputs appreciated

Andre Paradis