File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem submitting html:select value

 
Satyajeet Kumar
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Pallavi ch
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • 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().
 
Siddharth kumar
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, Lavanya do u mean in the same form bean a variable named cityName should be used.
 
Brent Sterling
Ranch Hand
Posts: 948
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic