• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

additional values in the dropdown

 
Rajani Deshpande
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't see how this relates to Struts. Just add more values to the ArrayList.
 
Rajani Deshpande
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that worked,
i was initially using htmlptions instead of htmlption and that was giving a weird error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic