Hello, I am learning how to use beans with jsp. As I understand it String values from request parametere can be automatically put into data fields using "property="*" in the jsp:setProprty tag. This is all very well, but what if you have a checkbox in your form which takes multiple selections? To get the values you would need to call getParameterValues(fieldname)which would return a String array, which could not go in a bean.
Are there any solutions to this? It seems a bit odd that simple fields can be assigned but as I understand it would you need a scriptlet to put the array into the bean???
but what if you have a checkbox in your form which takes multiple selections?
For a property that can posess multiple values, you need to be sure to set up the property in the JavaBean as an indexed property. Details on which accessors and mutators are necessary can be found here.
Once the bean is set up correctly for the indexed property, the multiple values get correctly added to the bean as an array.
P.S. This sort of thing is only necessary when you are submitting a form directly to a JSP. This structure for a web application is considered passe by today's conventional wisdom. In fact, the newly published March issue of the JavaRanch Journal has an article I wrote that discusses web application structures that you may find interesting.