code_junkie

Best Practice for Spring MVC form-backing object tree initialization

Nov 13th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. public class Person {
  2. String name;
  3. ContactInfo contactInfo = new ContactInfo();
  4. //getters, setters, etc.
  5. }
  6.  
  7. public class ContactInfo {
  8. String phone;
  9. Address homeAddress = new Address();
  10. }
  11.  
  12. public static Person getInstanceForContactInfoForm() {
  13. ContactInfo contactInfo = ContactInfo.getInstanceForContactInfoForm();
  14.  
  15. Person person = new Person(contactInfo);
  16. // set whatever other properties you need for Person
  17. // just enough to 1-render the form and 2-avoid any exceptions
  18. return person;
  19. }
Add Comment
Please, Sign In to add comment