aspose file tools*
The moose likes Struts and the fly likes Struts - DropDown Combination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts - DropDown Combination" Watch "Struts - DropDown Combination" New topic
Author

Struts - DropDown Combination

auvrm papu
Ranch Hand

Joined: Sep 01, 2005
Posts: 105
I have a dropdown in Struts-Jsp page

Iam displaying the State description the drop-down
The values would be for ex:
Alabama
Minnesota
etc..
using....

<html:select name="<%=formName%>" property="selectedState" >
<app ptionsCollection
name="<%=formName%>"
property="states"
label="description"
value="id"

/>

</html:select>

I would like to display them as,
AL- Alabama
MN- Minnesota
etc

basically, I want to have..
label="code-description"..

something like that..any idea?
Dave Hayward
Greenhorn

Joined: Feb 28, 2007
Posts: 14
If it were me, I would create a new getter method in the form that would return what you want. Something like:

Then in your html:select you would use "combinedLabel" instead of "description" for the label. Make sense?
You may not have this option, but it seems the easiest to me.


The worst thing with having everything is finding a place in the garage to keep it.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Dave's suggestion is good. Another option would be to iterate through the list of records returned from the database and populate your form with a list of LabelValueBean objects that have the desired label value.

BTW, I am a little curious about your usage of name="<%=formName%>". By default the html tags use the form name of the enclosing html:form tag if a name property is not given. I cannot remember a case where I used a scriptlet to populate the property.

- Brent
[ March 01, 2007: Message edited by: Brent Sterling ]
auvrm papu
Ranch Hand

Joined: Sep 01, 2005
Posts: 105
Dave, Thanks your idea worked..

Originally posted by Dave Hayward:
If it were me, I would create a new getter method in the form that would return what you want. Something like:

Then in your html:select you would use "combinedLabel" instead of "description" for the label. Make sense?
You may not have this option, but it seems the easiest to me.
 
wood burning stoves
 
subject: Struts - DropDown Combination