I have registered the "EntityEditor", the result of "PropertyEditorManager.findEditor(...)" should be EntityEditor. But actually the result is null, I'm quite confused about this. Anyone can help?
I use Oracle Java1.8 on MacOS-10.
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.beans.PropertyEditorSupport;
.......
.......
@Test
public void test3() {
PropertyEditorManager.registerEditor(Entity.class, EntityEditor.class);
PropertyEditor editor = PropertyEditorManager.findEditor(Entity.class);
}
static class EntityEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
Entity entity = new Entity(text);
setValue(entity);
}
}
static class Entity {
private String desc;
public Entity(String desc) {
this.desc = desc;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
Aucun commentaire:
Enregistrer un commentaire