You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by hellriserchet <r_...@yahoo.com> on 2008/05/09 16:23:48 UTC

How to pre-select a select list?

Hi everybody,

I have a form for updating the user information in my application. This form
is loaded when I click on an "update" link in my user information table.

The update form includes: username, password, and email fields, followed by
a drop-down list of available user groups that the user can be part of (this
list is dynamically generated from a table in DB). I easily pre-populate the
text fields like this:

<html:text property="name" name="editinguser"/>

where "editinguser" is the name of the bean containing the user object
information, stored in the session.

My problem is that I don't know how to pre-select the related user group in
the combo-box. At present my code is:

<html:select property="groupid">
  <html:options collection="allUserGroups" property="groupid"
labelProperty="groupname" />
  </html:select>

where allUserGroups is the collection containing the group objects. Now how
can I make the groupid of "editinguser" be selected in allUserGroups
combo-box?

TIA.

-- 
View this message in context: http://www.nabble.com/How-to-pre-select-a-select-list--tp17149112p17149112.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to pre-select a select list?

Posted by Laurie Harper <la...@holoweb.net>.
What do you mean by 'I uuse struts 2 package...'? The Struts1 tags don't 
work in Struts2 directly, so you may need to explain your setup in more 
detail to resolve specific issues.

That said, to answer the original question: have you tried using the 
same technique you did with the html:text tag? I.e. using both name and 
property attributes in the html:select tag? The should, I think, give 
you what you want.

L.

hellriserchet wrote:
> Hi Volker,
> 
> I'm actually new to struts. I use struts 2 package but all my learning
> resources including "struts for dummies" talk about struts 1, and I don't
> know how can I use the new tags, that's why I use these struts 1 tags!
> 
> How this problem is solved in struts 1? I hope I would not be forced to
> redesign all my work that's been done in struts 1.
> 
> Thanks.
> 
> 
> 
> 
> 
> Volker Karlmeier wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi,
>>
>> are you using struts1 ? This looks something strange to me.
>>
>> Just use
>> <s:select name="role"
>> ~                        list="availableRoles"                             
>> ~                        cssClass="input"/>       
>>
>> If you have getter and setter vor role (getRole()/setRole()) in your 
>> action class,
>> struts will populate (and select the proper entry) for you.
>>
>> Volker
>>
>>
>> hellriserchet schrieb:
>> | Hi everybody,
>> |
>> | I have a form for updating the user information in my application. 
>> This form
>> | is loaded when I click on an "update" link in my user information table..
>> |
>> | The update form includes: username, password, and email fields, 
>> followed by
>> | a drop-down list of available user groups that the user can be part of 
>> (this
>> | list is dynamically generated from a table in DB). I easily 
>> pre-populate the
>> | text fields like this:
>> |
>> | <html:text property="name" name="editinguser"/>
>> |
>> | where "editinguser" is the name of the bean containing the user object
>> | information, stored in the session.
>> |
>> | My problem is that I don't know how to pre-select the related user 
>> group in
>> | the combo-box. At present my code is:
>> |
>> | <html:select property="groupid">
>> |   <html:options collection="allUserGroups" property="groupid"
>> | labelProperty="groupname" />
>> |   </html:select>
>> |
>> | where allUserGroups is the collection containing the group objects. 
>> Now how
>> | can I make the groupid of "editinguser" be selected in allUserGroups
>> | combo-box?
>> |
>> | TIA.
>> |
>>
>>
>> - --
>> - -------------------------------
>>
>> Volker Karlmeier
>> Friedrich-Freye-Str. 61
>> 45481 Mülheim/Ruhr
>>
>> Tel. :  (+49) 208-7785675
>> Mobil:  (+49) 176-21056587
>> Mail :  Volker@magiccode.eu
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.7 (GNU/Linux)
>>
>> iD8DBQFIJZBxaEMQXBIqssERAujkAJ4vd53PIsism4QuuAH+4mPeLxRYNACdFtga
>> VsTiWQSiD68THHJ6ewbx3kI=
>> =Bnfo
>> -----END PGP SIGNATURE-----
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 



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


Re: How to pre-select a select list?

Posted by hellriserchet <r_...@yahoo.com>.
Hi Volker,

I'm actually new to struts. I use struts 2 package but all my learning
resources including "struts for dummies" talk about struts 1, and I don't
know how can I use the new tags, that's why I use these struts 1 tags!

How this problem is solved in struts 1? I hope I would not be forced to
redesign all my work that's been done in struts 1.

Thanks.





Volker Karlmeier wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> are you using struts1 ? This looks something strange to me.
> 
> Just use
> <s:select name="role"
> ~                        list="availableRoles"                             
> ~                        cssClass="input"/>       
> 
> If you have getter and setter vor role (getRole()/setRole()) in your 
> action class,
> struts will populate (and select the proper entry) for you.
> 
> Volker
> 
> 
> hellriserchet schrieb:
> | Hi everybody,
> |
> | I have a form for updating the user information in my application. 
> This form
> | is loaded when I click on an "update" link in my user information table.
> |
> | The update form includes: username, password, and email fields, 
> followed by
> | a drop-down list of available user groups that the user can be part of 
> (this
> | list is dynamically generated from a table in DB). I easily 
> pre-populate the
> | text fields like this:
> |
> | <html:text property="name" name="editinguser"/>
> |
> | where "editinguser" is the name of the bean containing the user object
> | information, stored in the session.
> |
> | My problem is that I don't know how to pre-select the related user 
> group in
> | the combo-box. At present my code is:
> |
> | <html:select property="groupid">
> |   <html:options collection="allUserGroups" property="groupid"
> | labelProperty="groupname" />
> |   </html:select>
> |
> | where allUserGroups is the collection containing the group objects. 
> Now how
> | can I make the groupid of "editinguser" be selected in allUserGroups
> | combo-box?
> |
> | TIA.
> |
> 
> 
> - --
> - -------------------------------
> 
> Volker Karlmeier
> Friedrich-Freye-Str. 61
> 45481 Mülheim/Ruhr
> 
> Tel. :  (+49) 208-7785675
> Mobil:  (+49) 176-21056587
> Mail :  Volker@magiccode.eu
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (GNU/Linux)
> 
> iD8DBQFIJZBxaEMQXBIqssERAujkAJ4vd53PIsism4QuuAH+4mPeLxRYNACdFtga
> VsTiWQSiD68THHJ6ewbx3kI=
> =Bnfo
> -----END PGP SIGNATURE-----
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-pre-select-a-select-list--tp17149112p17162734.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to pre-select a select list?

Posted by Volker Karlmeier <vo...@magiccode.eu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

are you using struts1 ? This looks something strange to me.

Just use
<s:select name="role"
~                        list="availableRoles"                             
~                        cssClass="input"/>       

If you have getter and setter vor role (getRole()/setRole()) in your 
action class,
struts will populate (and select the proper entry) for you.

Volker


hellriserchet schrieb:
| Hi everybody,
|
| I have a form for updating the user information in my application. 
This form
| is loaded when I click on an "update" link in my user information table.
|
| The update form includes: username, password, and email fields, 
followed by
| a drop-down list of available user groups that the user can be part of 
(this
| list is dynamically generated from a table in DB). I easily 
pre-populate the
| text fields like this:
|
| <html:text property="name" name="editinguser"/>
|
| where "editinguser" is the name of the bean containing the user object
| information, stored in the session.
|
| My problem is that I don't know how to pre-select the related user 
group in
| the combo-box. At present my code is:
|
| <html:select property="groupid">
|   <html:options collection="allUserGroups" property="groupid"
| labelProperty="groupname" />
|   </html:select>
|
| where allUserGroups is the collection containing the group objects. 
Now how
| can I make the groupid of "editinguser" be selected in allUserGroups
| combo-box?
|
| TIA.
|


- --
- -------------------------------

Volker Karlmeier
Friedrich-Freye-Str. 61
45481 Mülheim/Ruhr

Tel. :  (+49) 208-7785675
Mobil:  (+49) 176-21056587
Mail :  Volker@magiccode.eu

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFIJZBxaEMQXBIqssERAujkAJ4vd53PIsism4QuuAH+4mPeLxRYNACdFtga
VsTiWQSiD68THHJ6ewbx3kI=
=Bnfo
-----END PGP SIGNATURE-----


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