Class WmIdPropertyEditor
- java.lang.Object
-
- java.beans.PropertyEditorSupport
-
- nl.gx.webmanager.springmvc.editor.WmIdPropertyEditor
-
- All Implemented Interfaces:
PropertyEditor
public class WmIdPropertyEditor extends PropertyEditorSupport
This class represents a generic property editor for WmIds. It provides an editor for all classes that implement the WmId interface. The property editor invokes the EntityManager in order to transform a String to a WmId. Therefore the EntityManager is input parameter of the constructor of this property editor.Add this property editor in your initBinder method. For example to define a property editor for the language:public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); // Register basic property editors binder.registerCustomEditor(Language.class, new WmIdPropertyEditor(myEntityManager)); }
- Author:
- bartk
-
-
Constructor Summary
Constructors Constructor Description WmIdPropertyEditor(EntityManager entityManager)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAsText()
Format the WmId as String, using the .toString() method of the WmId implementations.void
setAsText(String text)
Parse the WmId from the given text-
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor
-
-
-
-
Constructor Detail
-
WmIdPropertyEditor
public WmIdPropertyEditor(EntityManager entityManager)
Constructor- Parameters:
entityManager
- the EntityManager
-
-
Method Detail
-
setAsText
public void setAsText(String text) throws IllegalArgumentException
Parse the WmId from the given text- Specified by:
setAsText
in interfacePropertyEditor
- Overrides:
setAsText
in classPropertyEditorSupport
- Throws:
IllegalArgumentException
-
getAsText
public String getAsText()
Format the WmId as String, using the .toString() method of the WmId implementations.- Specified by:
getAsText
in interfacePropertyEditor
- Overrides:
getAsText
in classPropertyEditorSupport
- Returns:
- Unique String representation of the WmId
-
-