Results 1 to 2 of 2

Thread: <Spring:bind> and constructing form backing object

  1. #1
    Join Date
    Jan 2007
    Posts
    10

    Default <Spring:bind> and constructing form backing object

    We are beginning to use Spring in our j2ee application and have a few questions.
    If I want to show a new form based on a complex nested object (for example A.B.C), I must fully construct it in formBackingObject() :

    new A(...,new B(..., new C(...)))

    If i construct the object only as

    new A()

    , it leads to NullValueInNestedPathException. Is our way showing new empty form the only one ?

    And what about the opposite direction? What if C can be null and I don't fill its atributes in form? I get again in onSubmit() full object A.B.C, not only A.B with C set to null.

    Is our way right or all this could be done better and simplier ?
    Thanks.

  2. #2
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Unfortunately that is currently the way things work. To solve this problem:
    And what about the opposite direction? What if C can be null and I don't fill its atributes in form? I get again in onSubmit() full object A.B.C, not only A.B with C set to null.
    You'll have to have some way of "trimming" empty children from your object tree after going through the binding process.
    Please see/vote for SPR-1671 so that this issue gets resolved
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •