Announcement Announcement Module
Collapse
No announcement yet.
Required fields name Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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 ?

    Comment

    Working...
    X