I'm creating a form with "add row" items and used AutoPopulatingList for spring. I started with the basic with just one row.
I have model:
ContractEntitlement.java
public class ContractEntitlement {
private String category;
getter and setter ....
}
I created a form class for the AutoPopulatingList:
CreateForm.java
@Entity
public class CreateForm {
private AutoPopulatingList contractEntitlements;
public AutoPopulatingList getContractEntitlements() {
return contractEntitlements;
}
public void setContractEntitlements(AutoPopulatingList contractEntitlements) {
this.contractEntitlements = contractEntitlements;
}
}
For my controller:
CreateController.java
@RequestMapping(value = "/create", method = RequestMethod.GET)
public String createForm(Model model) {
CreateForm createForm = new CreateForm();
// CreateForm sbf = new CreateForm();
// //sbf.getContractEntitlements().add(new ContractEntitlement());
// sbf.setContractEntitlements(new
// AutoPopulatingList(ContractEntitlement.class));
return "create";
}
For my jsp
Create.jsp
<spring:bind path="createForm.contractEntitlements[0].category">
<form:input path="${status.expression}" size="40" />
</spring:bind>
Notice in my controller I have commented out a few line of codes as I was testing to see which one works but all fails and I'm getting this error:
org.springframework.beans.NotReadablePropertyException: Invalid property 'contractEntitlement' of bean class [com.at.ccts.model.CreateForm]: Bean property 'contractEntitlement' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
If I use this in my controller
CreateForm sbf = new CreateForm();
sbf.setContractEntitlements(new
AutoPopulatingList(ContractEntitlement.class));
Error:
ERROR: org.springframework.web.servlet.tags.form.InputTag - Invalid property 'contractEntitlement' of bean class [com.at.ccts.model.CreateForm]: Bean property 'contractEntitlement' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
Am I missing something? Any ideas what causes the error?