• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem submitting html:select value

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

I have a <html:select> pull down list in my jsp page that is populated with values from database. I have used Arraylist in my Form-bean to populate the pull down list.

Now, when i am submitting the page i want the value selected in the pull down list (for some comparison purposes) in my Action class.

So, how will i get the selected value?
The problem is the Getter method in my Form-bean returns ArrayList and not String (as I have used ArrayList to populate the html:select control).

My Form bean :


My Jsp Page :

Pls, help out?
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this...

<html:select property="cityName">
<html ptionsCollection name="InfoForm" property="city" label="cLbl" value="cValue" />
</html:select>

and in the form bean - define this "cityName" variable and write getter and setter for that.
In your Action class, u get the selected value by using getCityName().
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, Lavanya do u mean in the same form bean a variable named cityName should be used.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct. Generally your form will have one property that represents the value of the selected item (this property is typically a String or long/int) and another property that represents all the available values in the list (this property can be some type of Collection or an array, I think).

- Brent
 
Siddharth kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, got it
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic