This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Comment

true , this works fine when you navigate to say a form and the controller form backing object returns a new object (with child objects created as defaults in the constructor of the pojo) . However , when you use that same form to edit data and the object is retrieved from the database say with hibernate .. you still end up with the same problem .. a null object reference unless of course the object is declared as a hibernate "component" in which case you will get a blank object back or the use the constructor to create the empty object.

Comment

thanks I see what your talking about and I appreciate your feedback, since our current domain model is somewhat frozen .. it's hard for me to incorporate the the defaults in the constructor. Is there some potentially less intrusive solution .. like when child objects that are null to suppress the bind error in the jsp. This way the domain would not have to be modified and when say an employee has no address the reference would be null .. as would expected to be and it would still bind to the jsp ?

Comment

lol , I knew that was the next solution coming .. looks good , but there are so many cases which this could happen ... I would need to duplicate all my input tags for this conditional logic ie .. if address is not null don't bind and use this input item , else bind and use this input item

Comment

good point , if anyone knows anything about property editors maybe u can answer this . The address in broken into 3 fields on the form .. I thought that with property editor your could only bind one field ? Three fields make up the address object ... can you use a property editor for this. (property editor folks ?)