aspose file tools*
The moose likes Struts and the fly likes additional values in the dropdown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "additional values in the dropdown" Watch "additional values in the dropdown" New topic
Author

additional values in the dropdown

Rajani Deshpande
Ranch Hand

Joined: May 08, 2000
Posts: 45
Hi,
I am currently picking all the values for a dropdown from the database. I am creating an array list. But how do I add a value to the dropdown list which is not in the database, like "Select" I want this to be the first one in the list and the other values below this.
One way is while creating the arraylist, add the value Select to the array list.
But Is there any way I can handle this at the jsp level?


Rajani
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Don't see how this relates to Struts. Just add more values to the ArrayList.
Rajani Deshpande
Ranch Hand

Joined: May 08, 2000
Posts: 45
HI,
Thats What I am doing now. But I want to use the same arraylist for some other business logic and would like it to contain only values from the database. SO I was wondering if struts allows me to add values other than that in the array list to the dropdown directly in the jsp page....
I have now:::
<html:select property="city" size="1" >
<html: options collection="cityList" property="value" labelProperty="label"/>
</html:select>
I would like :::
<html:select property="city" size="1" >
----add a dropdown value "select" here-----
<html: options collection="cityList" property="value" labelProperty="label"/>
----add a dropdown value "Other" here-----
</html:select>
[ December 03, 2002: Message edited by: Rajani Deshpande ]
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168

You need to code something for the value property, which should actually be part of your model.
<curse>Those smilies</curse>
[ December 03, 2002: Message edited by: Michael Zalewski ]
Rajani Deshpande
Ranch Hand

Joined: May 08, 2000
Posts: 45
Thanks, that worked,
i was initially using htmlptions instead of htmlption and that was giving a weird error.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: additional values in the dropdown
 
Similar Threads
Dynamic chnage on List from chnage on DropDown(ComboBox)
JSF dropdown components problem
how to populate dropdown box dynamically
Servlet loading
ice:selectOneMenu not refreshing