*
The moose likes Struts and the fly likes html:select problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:select problem" Watch "html:select problem" New topic
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: 4445
    
    5

I personally prefer htmlptionsCollection over htmlptions. The latter tag's attributes are, as you have seen, a bit confusing to use. The htmlptionsCollection 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]
chris gar
Ranch Hand

Joined: Jul 20, 2002
Posts: 45
Thanks! That did it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:select problem
 
Similar Threads
Help Please?
selecting a value in drop down box
html:checkbox or html:multibox
populating list boxes in forms - help required
using Formbean field in scripting