Hi, I'm trying to use a PropertyEditor to format the output of an entity in my jsp, but a strange error appears...
Suppose the entity Gender and a service with a method to retrieve genders from database by its identifier. So, the code would be... ("#" means "at" symbol - forum not allow me to post this character due to my post number)
and the binder:Code:public class GenderPropertyEditor extends PropertyEditorSupport { #Autowired private ResearcherService researcherService; public GenderPropertyEditor(){} public void setAsText(String text) { Gender gender; try { gender = researcherService.getGender(new Integer(text)); setValue(gender); } catch (NumberFormatException e) { setValue(null); } catch (InstanceNotFoundException e) { setValue(null); } } public String getAsText() { Gender gender = (Gender)getValue(); if (gender == null) return ""; return gender.getGenderID().toString(); } }
In debug mode, all data is filled correctly in property editor's methods, but the service is null. The service isn't being injected to this editor, but I can't found the reason.Code:public class LBDPortalBindingInitializer implements WebBindingInitializer { #InitBinder public void initBinder(WebDataBinder binder, WebRequest request) { binder.registerCustomEditor(Gender.class, new GenderPropertyEditor() ); } }
żAny missing annotation? żNeed more configuration?
Thanks


Reply With Quote
.
