Spring Framework ServletRequestDataBinder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ServletRequestDataBinder class.

This code example shows how to use the following methods:bind, getBindingResult, setConversionService, setValidator, validate
                        "    <street no=\"002\" name=\"street2\"/>\n" + 
                        "  </streets>\n" + 
                        "</address>"); 
 
        CreateUserRequest bindObject = BeanUtils.instantiateClass(CreateUserRequest.class); 
        ServletRequestDataBinder dataBinder = new ServletRequestDataBinder(bindObject, "bindObject"); 
        dataBinder.setConversionService(conversionService); 
        dataBinder.setValidator(getValidator()); 
        dataBinder.bind(request); 
        dataBinder.validate(); 
 
        assertTrue(dataBinder.getBindingResult().hasErrors()); 
        assertEquals(dataBinder.getBindingResult().getErrorCount(), 2); 
        CreateUserRequest createUserRequest = (CreateUserRequest) dataBinder.getBindingResult().getTarget(); 
        assertNotNull(createUserRequest.getAddress()); 
        assertNotNull(createUserRequest.getAddress().getStreets()); 
        assertTrue(createUserRequest.getAddress().getStreets().size() > 0); 
    } 
 
    private Validator getValidator() { 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getTarget, registerCustomEditor
	 
	/** Logger for this class and subclasses */ 
	protected final Log log = LogFactory.getLog(getClass()); 
	 
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { 
		super.initBinder(request, binder); 
		 
		// this depends on this form being a "session-form" (defined in openrms-servlet.xml) 
		Program program = (Program) binder.getTarget(); 
		 
		binder.registerCustomEditor(Concept.class, new ConceptEditor()); 
		binder.registerCustomEditor(java.util.Collection.class, "allWorkflows", new WorkflowCollectionEditor(program)); 
	} 
	 
	/** 
	 * This is called prior to displaying a form for the first time. It tells Spring the 
	 * form/command object to load into the request 
	 * 
	 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
	 */ 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerCustomEditor, bind, getBindingResult, setRequiredFields
	 * the user will need to correct; on success, a redirect to the "reward/show" 
	 * controller to display confirmed reward details 
	 */ 
	public ModelAndView create(HttpServletRequest request, HttpServletResponse response) { 
		RewardForm rewardForm = new RewardForm(); 
		ServletRequestDataBinder binder = new ServletRequestDataBinder(rewardForm, "rewardForm"); 
		// enforces these fields are present in the form 
		binder.setRequiredFields(new String[] { "creditCardNumber", "amount", "merchantNumber" }); 
		binder.registerCustomEditor(MonetaryAmount.class, new MonetaryAmountEditor()); 
		// copies parameters in the request to the reward form 
		binder.bind(request); 
		if (binder.getBindingResult().hasErrors()) { 
			return new ModelAndView("reward/new", binder.getBindingResult().getModel()); 
		} else { 
			Dining dining = rewardForm.createDining(); 
			RewardConfirmation confirmation = rewardNetwork.rewardAccountFor(dining); 
			return new ModelAndView("redirect:show/" + confirmation.getConfirmationNumber()); 
		} 
	} 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerCustomEditor
	 *  
	 * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, 
	 *      org.springframework.web.bind.ServletRequestDataBinder) 
	 */ 
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		super.initBinder(request, binder);
		binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
	} 
	 
	/** 
	 * This is called prior to displaying a form for the first time. It tells Spring the 
	 * form/command object to load into the request 
	 *  
	 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
	 */ 
	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
		 
		//default empty Object 
		List<ProviderAttributeType> providerAttributeTypeList = new Vector<ProviderAttributeType>();
		 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerCustomEditor
	public void setStateConversionValidator(StateConversionValidator stateConversionValidator) { 
		super.setValidator(stateConversionValidator); 
	} 
	 
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { 
		super.initBinder(request, binder); 
		 
		binder.registerCustomEditor(Concept.class, new ConceptEditor()); 
		binder.registerCustomEditor(ProgramWorkflow.class, new ProgramWorkflowEditor()); 
		binder.registerCustomEditor(ProgramWorkflowState.class, new ProgramWorkflowStateEditor()); 
	} 
	 
	/** 
	 * This is called prior to displaying a form for the first time. It tells Spring the 
	 * form/command object to load into the request 
	 *  
	 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
	 */ 
	protected Object formBackingObject(HttpServletRequest request) throws ServletException { 
		log.debug("called formBackingObject"); 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerCustomEditor
     * @param binder the data binder 
     */ 
    @InitBinder 
    protected void initBinder(HttpServletRequest request, 
                              ServletRequestDataBinder binder) { 
        binder.registerCustomEditor(Integer.class, null, 
                                    new CustomNumberEditor(Integer.class, null, true)); 
        binder.registerCustomEditor(Long.class, null, 
                                    new CustomNumberEditor(Long.class, null, true)); 
        binder.registerCustomEditor(byte[].class, 
                                    new ByteArrayMultipartFileEditor()); 
        SimpleDateFormat dateFormat =  
            new SimpleDateFormat(getText("date.format", request.getLocale())); 
        dateFormat.setLenient(false); 
        binder.registerCustomEditor(Date.class, null,  
                                    new CustomDateEditor(dateFormat, true)); 
    } 
 
    /** 
     * Convenience message to send messages to users, includes app URL as footer. 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerCustomEditor
	 *  
	 * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, 
	 *      org.springframework.web.bind.ServletRequestDataBinder) 
	 */ 
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		super.initBinder(request, binder);
		binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
	} 
	 
	/** 
	 * This is called prior to displaying a form for the first time. It tells Spring the 
	 * form/command object to load into the request 
	 *  
	 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
	 */ 
	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
		 
		//default empty Object 
		List<VisitAttributeType> visitAttributeTypeList = new Vector<VisitAttributeType>();
		 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerCustomEditor
	 * 
	 * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, 
	 *      org.springframework.web.bind.ServletRequestDataBinder) 
	 */ 
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { 
		super.initBinder(request, binder); 
		 
		//NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); 
		binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); 
		binder.registerCustomEditor(java.lang.Double.class, new CustomNumberEditor(java.lang.Double.class, true)); 
		binder.registerCustomEditor(Concept.class, new ConceptEditor()); 
	} 
	 
	/** 
	 * The onSubmit function receives the form/command object that was modified by the input form 
	 * and saves it to the db 
	 * 
	 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, 
	 *      javax.servlet.http.HttpServletResponse, java.lang.Object, 
	 *      org.springframework.validation.BindException) 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerCustomEditor
	 *  
	 * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, 
	 *      org.springframework.web.bind.ServletRequestDataBinder) 
	 */ 
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		super.initBinder(request, binder);
		binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
	} 
	 
	/** 
	 * This is called prior to displaying a form for the first time. It tells Spring the 
	 * form/command object to load into the request 
	 *  
	 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
	 */ 
	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
		 
		//default empty Object 
		List<HL7Source> hl7SourceList = new Vector<HL7Source>();
		 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerCustomEditor
	 *  
	 * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, 
	 *      org.springframework.web.bind.ServletRequestDataBinder) 
	 */ 
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		super.initBinder(request, binder);
		binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
	} 
	 
	/** 
	 * This is called prior to displaying a form for the first time. It tells Spring the 
	 * form/command object to load into the request 
	 *  
	 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
	 */ 
	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
		 
		//default empty Object 
		List<VisitType> visitTypeList = new Vector<VisitType>();
		 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework ServletRequestDataBinder Methods: