I have a <form:radiobuttons> component in my jsp page which binds to a collection.
example
I bind this data in jsp as belowCode:public class Test { private Sex sex; private String[] sexes = {"male", "female"}; public String[] getSexes() { return sexes; } public void setSexes(String[] sexes) { this.sexes = sexes; } public Sex getSex() { return sex; } public void setSex(Sex sexes) { this.sex = sex; } }
My Sex object contain Male and M for description and code. Male is selected.Code:<form:radiobuttons items="${test.sexes}" path="Sex.description"/>
This works fine.
But when I try to use List<Sex> like this.
Code:public class Test { private Sex sex; private List<Sex> sexes; public List<Sex> getSexes() { return sexes; } public void setSexes(List<Sex> sexes) { this.sexes = sexes; } public Sex getSex() { return sex; } public void setSex(Sex sexes) { this.sex = sex; } }Male is not selected. Same thing happens when I use <form:Select>Code:<form:radiobuttons items="${test.sexes}" path="Sex.description" itemLabel="description"/>
Can anyone tell what am I doing wrong?
Thanks.
KM


Reply With Quote