@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( Long.class, new CustomNumberEditor(Long.class, true)); binder.registerCustomEditor( Double.class, new CustomNumberEditor(Double.class, true)); binder.registerCustomEditor( BigDecimal.class, new CustomNumberEditor( BigDecimal.class, new DecimalFormat("#,##0.00"), true)); binder.registerCustomEditor( Boolean.class, new CustomBooleanEditor(true)); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); binder.registerCustomEditor( Object.class, new ObjectTypeEditorHelper()); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.setAutoGrowNestedPaths(false); binder.registerCustomEditor( Long.class, new CustomNumberEditor(Long.class, true)); binder.registerCustomEditor( Double.class, new CustomNumberEditor(Double.class, true)); binder.registerCustomEditor( BigDecimal.class, new CustomNumberEditor( BigDecimal.class, new DecimalFormat("#,##0.00"), true)); binder.registerCustomEditor( Boolean.class, new CustomBooleanEditor(true)); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); binder.registerCustomEditor( Object.class, new ObjectTypeEditorHelper()); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( byte[].class, new ByteArrayMultipartFileEditor()); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); binder.registerCustomEditor( Long.class, new CustomNumberEditor(Long.class, true)); binder.registerCustomEditor( Double.class, new CustomNumberEditor(Double.class, true)); binder.registerCustomEditor( BigDecimal.class, new CustomNumberEditor( BigDecimal.class, new DecimalFormat("#,##0.00"), true)); binder.registerCustomEditor( Boolean.class, new CustomBooleanEditor(false)); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( Long.class, new CustomNumberEditor(Long.class, true)); binder.registerCustomEditor( Double.class, new CustomNumberEditor(Double.class, true)); binder.registerCustomEditor( BigDecimal.class, new CustomNumberEditor( BigDecimal.class, new DecimalFormat("#,##0.00"), true)); binder.registerCustomEditor( Boolean.class, new CustomBooleanEditor(false)); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); }
@Test public void transformTagNonExistingValue() throws JspException { // first set up the pagecontext and the bean PageContext pc = createPageContext(); TestBean tb = new TestBean(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "tb"); CustomDateEditor l = new CustomDateEditor(df, true); binder.registerCustomEditor(Date.class, l); pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", binder.getBindingResult()); // try with non-existing value BindTag bind = new BindTag(); bind.setPageContext(pc); bind.setPath("tb.name"); bind.doStartTag(); TransformTag transform = new TransformTag(); transform.setPageContext(pc); transform.setValue(null); transform.setParent(bind); transform.setVar("theString2"); transform.doStartTag(); assertNull(pc.getAttribute("theString2")); }
@InitBinder public void initBinder(ServletRequestDataBinder binder) { /** * 自动转换日期类型的字段格式 */ binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true)); /** * 防止XSS攻击 */ binder.registerCustomEditor(String.class, new StringEscapeEditor()); }
@InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat( TodoListUtils.DATE_FORMAT); binder.registerCustomEditor(Date.class, new CustomDateEditor( dateFormat, false)); binder.registerCustomEditor(Priority.class, new TodoPriorityPropertyEditor()); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); binder.registerCustomEditor( Object.class, new ObjectTypeEditorHelper()); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( byte[].class, new ByteArrayMultipartFileEditor()); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); binder.registerCustomEditor( Long.class, new CustomNumberEditor(Long.class, true)); binder.registerCustomEditor( Double.class, new CustomNumberEditor(Double.class, true)); binder.registerCustomEditor( BigDecimal.class, new CustomNumberEditor( BigDecimal.class, new DecimalFormat("#,##0.00"), true)); binder.registerCustomEditor( Boolean.class, new CustomBooleanEditor(false)); binder.registerCustomEditor( Object.class, new ObjectTypeEditorHelper()); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(String.class, new StringTrimmerEditor(true)); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( Long.class, new CustomNumberEditor(Long.class, true)); binder.registerCustomEditor( Double.class, new CustomNumberEditor(Double.class, true)); binder.registerCustomEditor( BigDecimal.class, new CustomNumberEditor( BigDecimal.class, new DecimalFormat("#,##0.00"), true)); binder.registerCustomEditor( Boolean.class, // new CustomBooleanEditor(false)); new CustomBooleanEditor(true)); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); // binder.registerCustomEditor( // TerminiDto.class, // new TerminiTypeEditorHelper()); binder.registerCustomEditor( Object.class, new ObjectTypeEditorHelper()); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(String.class, new StringTrimmerEditor(true)); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); binder.registerCustomEditor( Object.class, new ObjectTypeEditorHelper()); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( byte[].class, new ByteArrayMultipartFileEditor()); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( boolean.class, new CustomBooleanEditor(false)); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( boolean.class, new CustomBooleanEditor(false)); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); binder.registerCustomEditor( Permis.class, new PermisTypeEditor()); }
@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor( ExpedientTipus.class, new ExpedientTipusTypeEditor(dissenyService)); binder.registerCustomEditor( Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true)); }
@Override public void initBinder(WebDataBinder binder, WebRequest request) { assertNotNull(request.getLocale()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); }
@Test public void bindingDate() throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); Date expected = dateFormat.parse("06-03-2006"); request.addParameter("date", "06-03-2006"); PortletRequestDataBinder binder = new PortletRequestDataBinder(bean); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); binder.bind(request); assertEquals(expected, bean.getDate()); }
@SuppressWarnings("unused") @InitBinder private void initBinder(WebDataBinder binder) { binder.initBeanPropertyAccess(); binder.setRequiredFields("sex"); LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean(); vf.afterPropertiesSet(); binder.setValidator(vf); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); }
@SuppressWarnings("unused") @InitBinder({"myCommand", "date"}) private void initBinder(WebDataBinder binder, String date, @RequestParam("date") String[] date2) { LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean(); vf.afterPropertiesSet(); binder.setValidator(vf); assertEquals("2007-10-02", date); assertEquals(1, date2.length); assertEquals("2007-10-02", date2[0]); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); }
@InitBinder public void initBinder(WebDataBinder binder, @PathVariable("hotel") String hotel) { assertEquals("Invalid path variable value", "42", hotel); binder.initBeanPropertyAccess(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); }