Announcement Announcement Module
Collapse
No announcement yet.
Spring:bind and nested objects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring:bind and nested objects

    Hi

    1.I am using a multi action controller which loads a form

    i need to load the form which has nested object eg

    class parent{
    int id
    string name;

    Child x;
    Child y;

    }

    Class child{
    string addr1;

    }


    2. I tried using sping:bind to bind the input fields in jsp to the object when i submit the form it goes to a multi action controller.

    Problem is

    1. i am not able to retrieve the values from nested object child in m jsp
    2.when i submit the form it throws exception invalid child -null

    is there any thing i need to include in cotroller to get nested values ?


    thanks

  • #2
    nested object

    eg




    <spring:bind path="company.address.street">
    Name: <input
    type="text"
    value="<c:out value="${status.value}"/>"
    name="<c:out value="${status.expression}"/>">
    <c:if test="${status.error}">
    Error codes:
    <c:forEach items="${status.errorMessages}" var"error">
    <c:out value="${error}"/>
    </c:forEach>
    </c:if>
    </spring:bind>
    when i submit
    in controller i get null address

    if address street has values it doenot get displayed in textbox

    Comment


    • #3
      Please post also the SimpleFormController code... atleast "formBackingObject()" and "referenceData()" methods from it.

      FYI
      When you post code, use <CODE>your code here</CODE> tags (just replace the <> with brackets []. By this, the post is more readable.

      Comment


      • #4
        hi

        i am just calling

        showMyView(req,res) - which just set my cmpany object in request and forwards to my jsp page

        on submit i call

        saveMyValues(http..req,res,Company command) function

        both these functions are in multi action controller


        i can get simple values like command.getCompanyName() etc

        but if i bind company.address in my jsp ,on form submit i get null exception

        Comment

        Working...
        X