| Author |
html:select problem
|
chris gar
Ranch Hand
Joined: Jul 20, 2002
Posts: 45
|
|
I have done many searches but I don't understand. I have an ArrayList "probationOfficers" defined in "MyActionForm". Currently, my code displays and retrieves the name of the probation officer. Here is the code: If I load data from an action I have to send (to the jsp) the name - like "Johnson" in order to display the right selection. Likewise, I receive "Johnson" in the action upon a submit etc. I need to be able to send (for instance) id = 4 to the jsp and have that code display the appropriate name (Johnson)- and I need a 4 also on submit. I have read many posts and i'm not getting it - I'm sure which is which - collection - property -labelProperty - name. Can someone please provide some assistance. Regards.
|
 |
unni krishna
Ranch Hand
Joined: Jul 14, 2004
Posts: 39
|
|
This is an usual stuff that every one does in struts, See this post in Javaranch, http://www.coderanch.com/t/45981/Struts/struts-html-options-tag-not
|
Software Engineer (SCJP)<br />USTechnology, CA
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4133
|
|
I personally prefer html ptionsCollection over html ptions. The latter tag's attributes are, as you have seen, a bit confusing to use. The html ptionsCollection attributes, on the other hand, are more straightforward and intuitive. You can read the JSP like so: create a drop down; the value selected for this dropdown should go into the "probationOfficer" property of the form. The options for the dropdown are in the Collection returned by the "officers" property of the form. The label to show for the options should be the "name" of each officer in the collection. The value to use to set the enclosing "select" tag when a selection is made is the "id" of the officer selected. [ January 04, 2005: Message edited by: Junilu Lacar ]
|
Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
|
 |
chris gar
Ranch Hand
Joined: Jul 20, 2002
Posts: 45
|
|
Thanks! That did it!
|
 |
 |
|
|
subject: html:select problem
|
|
|