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

  • Property Editors

    Hi,

    Could some one please explain what Property Editors are used for and give some simple examples?

    Thanks.

  • #2
    PropertyEditors are used in a few places, but basically they are for converting from String to other types and back again. For example, a date can be represented as a String, and you'd use a property editor to convert it.

    This is especially useful in web requests, because the Strings in the web request can be bound directly to your command object (bypassing the need for an object like Struts ActionForms). For example:

    Code:
        protected void initBinder(HttpServletRequest request,
            ServletRequestDataBinder binder) {
    
            SimpleDateFormat dateFormat = new SimpleDateFormat("MMM-yy");
            dateFormat.setLenient(false);
            binder.registerCustomEditor(Date.class, null,
                new CustomDateEditor(dateFormat, true));
        }
    The best place to look are the reference docs. See Registering additional custom PropertyEditors.

    Comment

    Working...
    X