• Post Reply Bookmark Topic Watch Topic
  • New Topic

initBinder method - how does it works?

 
Pradeep Arun
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am bit confused with initBinder method available in Spring.

How it works?
Whats the use of it?
In what scenario should we use it?

I have a textbox which is tied to java.util.Date property in CommandBean. I used the below code for binding

protected void initBinder(HttpServletRequest request,
ServletRequestDataBinder binder) throws Exception {
binder.registerCustomEditor(Date.class,
new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), false));
}

But when i enter 02/12/2009 or any text value its not throwing any error message. if i enter 02-12-2009 it works. I am totally confused

Please clarify.

Thanks,
Pradeep
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!