This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Struts combo box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts combo box" Watch "Struts combo box" New topic
Author

Struts combo box

starts singh
Greenhorn

Joined: Mar 18, 2008
Posts: 3
I have a combo box defined in JSP.
So when I submit the page with multiple values selected in thsi combo box, I get "argument type mismatch exception" for the setter method defined in actionForm for this combo box. This method has a return type "Collection". Where do you think I am going wrong? What should be the return type here? I had String before but with I could get only the one value from the combo box
(i.e first selected value).
starts singh
Greenhorn

Joined: Mar 18, 2008
Posts: 3
Ok, Actionform accept only string arrays not collecion or arraylists...but why?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by starts singh:
Ok, Actionform accept only string arrays not collecion or arraylists...but why?

Because the HTML protocol only deals in Strings, not other Java object types. The Struts ActionForm setter method is taking as it's parameter input from an HTML form. The only type of data an HTML form understands is a String.


Merrill
Consultant, Sima Solutions
starts singh
Greenhorn

Joined: Mar 18, 2008
Posts: 3
Makes sense, Merrill. Thanks!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts combo box