views:

41

answers:

1

Using Grails 1.2.2, I'm working on binding a structured property (CC expiration Date) to a java.util.Date but only for specific Domain and Commands objects.

I've found the StructuredPropertyEditor interface, but the only way that I've found to register it is to use the PropertyEditorRegistrar and register the editor for the java.util.Date class (much like this example)

I don't want all of my dates to use my custom StructuredPropertyEditor. How do I apply the StructuredPropertyEditor selectively to specific targets like certain Command & Domain Classes?

A: 

can't you specify the custom type (cc expiration date model) for the registration?. It worked for me for money representation

public class CCExpirationPropertyEditorRegistrar implements PropertyEditorRegistrar {

    public void registerCustomEditors(PropertyEditorRegistry registry) {
      registry.registerCustomEditor(CCExpirationClass.class, new CCExpirationEditor());
    }
}
bsreekanth