tnist
Nov 23rd, 2004, 02:46 PM
I have been working on trying to figure how best to implement a page where I have dynamic list binding. It seems as though I may need to implemanet a custom PropertyEditor to handle this, but I'm not quite sure.
I have the following domain objects:
public class Claim {
private Long trackingID;
private Long transactionID;
private Date dateCreated;
private Date dateReceived;
private String employeeID;
private String employeeName;
private String claimID;
private String formType;
private List lines = new ArrayList(); /** Detail Line(s) associated with claim */
}
public class ClaimLine {
private Long id;
private int lineNumber;
private Date serviceDate;
private String category;
private Double amount;
private int eligibilityCode;
private String eligibilityComment;
private int duplicate;
}
The Web UI allows the user to insert row via JavaScript and DHTML into the table that conform to the following:
lines[n].serviceDate
lines[n].amount
lines[n].category
lines[n].eligibilityComment
lines[n].eligibilityCode
where n is the next element in the collection to insert.
When I post the form back, the bindAndValidate() method is invoked on the BaseCommandController and throws and exception the following exception:
org.springframework.beans.InvalidPropertyException : Invalid property 'lines[7]' of bean class [mycompany.com.claims.model.Claim]: Index of out of bounds in property path 'lines[7]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 7, Size: 7
java.lang.IndexOutOfBoundsException: Index: 7, Size: 7
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at net.sf.hibernate.collection.List.get(List.java:217 )
at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:522)
at org.springframework.beans.BeanWrapperImpl.getNeste dBeanWrapper(BeanWrapperImpl.java:423)
at org.springframework.beans.BeanWrapperImpl.getBeanW rapperForPropertyPath(BeanWrapperImpl.java:401)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:580)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:720)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:747)
at org.springframework.validation.DataBinder.bind(Dat aBinder.java:240)
at org.springframework.web.bind.ServletRequestDataBin der.bind(ServletRequestDataBinder.java:173)
at org.springframework.web.servlet.mvc.BaseCommandCon troller.bindAndValidate(BaseCommandController.java :294)
at org.springframework.web.servlet.mvc.AbstractFormCo ntroller.handleRequestInternal(AbstractFormControl ler.java:236)
at org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:128)
at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:44)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:522)
at org.springframework.web.servlet.FrameworkServlet.s ervice(FrameworkServlet.java:321)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
The exception is expected since the current model (command object) Claim does not contain the appropriate number of entries in the Lines collection.
How do I implement a PropertyEditor in initBinder to have access to the Claim (command object), insert 1..n new claim lines and then invoke the standard bind? Or can I do this?
Thanks in advance for you assistance.
Regards,
Todd
I have the following domain objects:
public class Claim {
private Long trackingID;
private Long transactionID;
private Date dateCreated;
private Date dateReceived;
private String employeeID;
private String employeeName;
private String claimID;
private String formType;
private List lines = new ArrayList(); /** Detail Line(s) associated with claim */
}
public class ClaimLine {
private Long id;
private int lineNumber;
private Date serviceDate;
private String category;
private Double amount;
private int eligibilityCode;
private String eligibilityComment;
private int duplicate;
}
The Web UI allows the user to insert row via JavaScript and DHTML into the table that conform to the following:
lines[n].serviceDate
lines[n].amount
lines[n].category
lines[n].eligibilityComment
lines[n].eligibilityCode
where n is the next element in the collection to insert.
When I post the form back, the bindAndValidate() method is invoked on the BaseCommandController and throws and exception the following exception:
org.springframework.beans.InvalidPropertyException : Invalid property 'lines[7]' of bean class [mycompany.com.claims.model.Claim]: Index of out of bounds in property path 'lines[7]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 7, Size: 7
java.lang.IndexOutOfBoundsException: Index: 7, Size: 7
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at net.sf.hibernate.collection.List.get(List.java:217 )
at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:522)
at org.springframework.beans.BeanWrapperImpl.getNeste dBeanWrapper(BeanWrapperImpl.java:423)
at org.springframework.beans.BeanWrapperImpl.getBeanW rapperForPropertyPath(BeanWrapperImpl.java:401)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:580)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:720)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:747)
at org.springframework.validation.DataBinder.bind(Dat aBinder.java:240)
at org.springframework.web.bind.ServletRequestDataBin der.bind(ServletRequestDataBinder.java:173)
at org.springframework.web.servlet.mvc.BaseCommandCon troller.bindAndValidate(BaseCommandController.java :294)
at org.springframework.web.servlet.mvc.AbstractFormCo ntroller.handleRequestInternal(AbstractFormControl ler.java:236)
at org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:128)
at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:44)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:522)
at org.springframework.web.servlet.FrameworkServlet.s ervice(FrameworkServlet.java:321)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
The exception is expected since the current model (command object) Claim does not contain the appropriate number of entries in the Lines collection.
How do I implement a PropertyEditor in initBinder to have access to the Claim (command object), insert 1..n new claim lines and then invoke the standard bind? Or can I do this?
Thanks in advance for you assistance.
Regards,
Todd