List of usage examples for org.springframework.beans PropertyEditorRegistry findCustomEditor
@Nullable PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath);
From source file:org.kuali.rice.krad.uif.util.ObjectPropertyUtils.java
/** * Gets a property editor given a specific bean and property path. * //from ww w. java 2 s. c om * @param bean The bean instance. * @param path The property path. * @return property editor */ public static PropertyEditor getPropertyEditor(Object bean, String path) { Class<?> propertyType = getPrimitiveType(getPropertyType(bean, path)); PropertyEditor editor = null; PropertyEditorRegistry registry = getPropertyEditorRegistry(); if (registry != null) { editor = registry.findCustomEditor(propertyType, path); if (editor != null && editor != registry.findCustomEditor(propertyType, null)) { return editor; } if (registry instanceof BeanWrapper && bean == ((BeanWrapper) registry).getWrappedInstance() && (bean instanceof ViewModel)) { ViewModel viewModel = (ViewModel) bean; ViewPostMetadata viewPostMetadata = viewModel.getViewPostMetadata(); PropertyEditor editorFromView = viewPostMetadata == null ? null : viewPostMetadata.getFieldEditor(path); if (editorFromView != null) { registry.registerCustomEditor(propertyType, path, editorFromView); editor = registry.findCustomEditor(propertyType, path); } } } if (editor != null) { return editor; } return getPropertyEditor(propertyType); }
From source file:org.kuali.rice.krad.uif.util.ObjectPropertyUtils.java
/** * Get a property editor given a property type. * * @param propertyType The property type to look up an editor for. * @param path The property path, if applicable. * @return property editor/*ww w . j av a2s . c o m*/ */ public static PropertyEditor getPropertyEditor(Class<?> propertyType) { PropertyEditorRegistry registry = getPropertyEditorRegistry(); PropertyEditor editor = null; if (registry != null) { editor = registry.findCustomEditor(propertyType, null); } else { DataDictionaryService dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService(); Map<Class<?>, String> editorMap = dataDictionaryService.getPropertyEditorMap(); String editorPrototypeName = editorMap == null ? null : editorMap.get(propertyType); if (editorPrototypeName != null) { editor = (PropertyEditor) dataDictionaryService.getDataDictionary() .getDictionaryPrototype(editorPrototypeName); } } if (editor == null && propertyType != null) { // Fall back to default beans lookup editor = PropertyEditorManager.findEditor(propertyType); } return editor; }