Results 1 to 3 of 3

Thread: binding causes null properties for nested object

  1. #1
    Join Date
    Aug 2004
    Posts
    9

    Default binding causes null properties for nested object

    I have a UserForm with a nested User class. When I submit the form, the properties are all set to null and don't seem to be binding the nested form values. It is picking up the UserForm properties correctly.

    I know this has to be some simple syntax problem, but I've been racking my brain over it for too long and need some help!

    Kim


    edit.jsp:
    Code:
    	<spring&#58;bind path="userForm.user.firstName">
    		<input type="text" name="firstName" id="firstName" value="$&#123;status.value&#125;" class="text"/>
    		<c&#58;if test="$&#123;not empty status.errorMessage&#125;"><span class="fieldError">$&#123;status.errorMessage&#125;</span></c&#58;if>
    	</spring&#58;bind>
    UserForm.java:
    Code:
    public class UserForm &#123;
        
        private User user;
        private boolean newUser;
        private String repeatedPassword;
    
    // getters and setters follow
    &#125;
    User.java:
    Code:
    public class User implements Serializable&#123;
        
        static final long serialVersionUID = -3202570521013016218L;
        
        private String username;
        private String password;
        private boolean enabled;
        private String firstName;
        private String lastName;
    
    // getters and setters follow
    &#125;

    action-servlet.xml:
    Code:
        <bean id="userFormController" class="com.tripshare.web.manage.UserFormController">
            <property name="commandName"><value>userForm</value></property>
            <property name="commandClass"><value>com.example.web.manage.UserForm</value></property>
            <property name="validator"><ref bean="beanValidator"/></property>
            <property name="formView"><value>manage/users/edit</value></property>       
            <property name="successView"><value>redirect&#58;/manage/users/index.html</value></property>
    
            <property name="sessionForm"><value>true</value></property>
            <property name="bindOnNewForm"><value>true</value></property>
        </bean>

  2. #2
    Join Date
    Aug 2004
    Posts
    9

    Default

    I neglected to mention I'm using 1.2-rc2.

  3. #3
    Join Date
    Aug 2004
    Posts
    9

    Default

    As I guessed, it was a simple syntax problem. I was using Matt Raible's equinox jsp as a template, and the 'name' attribute of the text field was hard-coded to 'firstName'. As I am using a nested bean, the actual name of the form needed to be 'user.firstName'.

    This can be obtainedby using the ${status.expression} variable for the field 'name' attribute inside the <spring:bind> tag, as per the jpetstore example.
    Kim Pepper

Similar Threads

  1. FlowExecutionStorage in a DB
    By cacho in forum Web Flow
    Replies: 7
    Last Post: Oct 19th, 2009, 03:36 PM
  2. Replies: 2
    Last Post: Oct 17th, 2005, 08:41 PM
  3. Replies: 4
    Last Post: Sep 27th, 2005, 11:31 PM
  4. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  5. Strange Data Access Error
    By webifyit in forum Data
    Replies: 2
    Last Post: Dec 28th, 2004, 11:06 AM

Posting Permissions

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