Results 1 to 2 of 2

Thread: Required fields name

  1. #1
    Join Date
    Jul 2008
    Posts
    239

    Default Required fields name

    Hi.
    Consider these classes

    Code:
    public class Registration {
        private Subject user = new Subject();
        private String passwordConfirmation;
    }
    
    
    public class Subject{
        private String name;
        private String password;
    }
    
    public class RegistrationController extends SimpleFormController {
        private static final String[] REQUIRED_FIELDS = new String[]{
    	"user.name",
    	"user.password",
    	"passwordConfirmation"
        };
        
        @Override
        public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    	binder.setRequiredFields(REQUIRED_FIELDS);
        }
    }
    Are the REQUIRED_FIELDS correctly specified ?
    How should they be specified anyway if they aren't?

    Thanks !


    P.S. the "user" thing is like in "e.pushNestedPath("user");"

  2. #2
    Join Date
    Jul 2008
    Posts
    239

    Default

    Code:
    if (e.getFieldErrorCount("passwordConfirmation") == 0 && !reg.getUser().getPassword().equals(reg.getPasswordConfirmation())) {
    	    e.rejectValue("passwordConfirmation", "passwordConfirmationMismatch");
    	}

    When execution goes to this, then getPassword returns null, and NullPointerException gets raised.

    Somewhere something is wrong... Can you help me find what it is ?

Posting Permissions

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