my dog learned polymorphism*
The moose likes Struts and the fly likes Problem passing parameter with optionsCollection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem passing parameter with optionsCollection" Watch "Problem passing parameter with optionsCollection" New topic
Author

Problem passing parameter with optionsCollection

Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
Hello, I�m trying to show a select box but I just get a: "No getter method available for property rol for bean under name AdminForm" when trying to show the JSP page.
Problem is, the property rol is there...

This is the select box in the JSP


I pass the ArrayList listaRoles with setAttribute from the Action to the JSP. This ArrayList have a list of beans RolBean:

with his getter and setters.

The adminForm:


Can someone help with this? Thanks and sorry for my english
[ August 06, 2007: Message edited by: Mario Romero ]

.NET & JSP developer for <a href="http://www.grupocartuja.com" target="_blank" rel="nofollow"> Grupo Cartuja</a><br /> <br />Currently moving the webpage from ASP to Struts (mostly the Intranet)
Ranjit Gopinathan
Ranch Hand

Joined: Jul 03, 2007
Posts: 46
Is public getters/setters for rol defined in adminForm ?
Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
Yes, I automatically generated them with eclipse.
Ranjit Gopinathan
Ranch Hand

Joined: Jul 03, 2007
Posts: 46
Is that "name" attribute really required in the select tag, since it is already inside an html form?. Am not sure about if this is going to help or not.
Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
As far as I know adminForm is optional, whenever I remove it in the select or the optionCollection it doesnt change anything (to my error I mean)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Since the rol property is an array, you must specify multiple="true" in your html:select tag. For more information, see the heading select in this link.


Merrill
Consultant, Sima Solutions
Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
Thanks a lot! That worked. I though "multiple" referred to select more than one at the same time. Presupposing is one of the worst error one can�t debug.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Mario Romero:
I though "multiple" referred to select more than one at the same time.

Actually, you're right -- multiple does mean that you can select more than one at a time. That's why it requires an array to hold the result. If you do not intend for the user to select more than one value, make rol an int or a String and remove the multiple="true" from your select tag. The important thing is that the tag and the property must be consisitent. If the property is an array, the tag must allow for multiple values to be selected. If the property is a single value, the tag must not allow for multiple values to be selected.
Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
..strange, the problem was with the array of "rol" in the ActionForm.

Whenever the select has multiple=true or not, rol must be an array or it won�t get the value, so I have to use rol[0] later.
Looks like I did something wrong but I checked the form getters and setters and I dont see anything bad.
At least is working, thanks again.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Mario Romero:
Whenever the select has multiple=true or not, rol must be an array or it won�t get the value

I'm glad it's working, Mario, but the above statement simply isn't true. If you don't specify multiple="true" in an <html:select> the property can be a String or int, not an array and it will get populated just fine.
[ August 08, 2007: Message edited by: Merrill Higginson ]
Mario Romero
Greenhorn

Joined: Aug 06, 2007
Posts: 18
I know it�s not logic, but that�s what I�m doing and works.
Perhaps something barely related with this is not right in some part of my code, but for the record, this is what I have actually:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem passing parameter with optionsCollection