I'm trying to populate a select with Struts. However, I'm getting this error message:
No getter method available for property label under name com.packagename.branchImpl
There is no variable called 'label' in the class in which its looking either, so I don't know how it is looking for label
form class is a very typical entity class
any suggestions as to why this error occurs?
It could be a typo with <cain:optionsCollection
should be <html:optionsCollection
. The last tag uses a property
attribute for the collection of beans that have label
and value
properties. If you have a different property names in the collection bean then it could be specified using the label
and value
attributes of the tag. For example if you have a collection List<MyBean>
and
public class MyBean implements Serializable {
private String key;
private String name;
//getters and setters for both
}
then you should use
<html:select name="querySwiftLogForm" property="branch" >
<html:optionsCollection name="querySwiftLogForm" property="branchList" label="name" value="key"/>
</html:select>
If you don't have a bean that you could use with the collection, then you could use LabelValueBean
. And you need to fill the collection with the instances of that bean. Then lable
and value
attributes not necessary for that bean because it will use the defaults.
Also, if you use the form that is mapped to the action then name
attribute is not necessary.