List of usage examples for org.springframework.web.bind ServletRequestDataBinder registerCustomEditor
@Override
public void registerCustomEditor(@Nullable Class<?> requiredType, @Nullable String field,
PropertyEditor propertyEditor)
From source file:com.opencart.controller.AdminController.java
@InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(Category.class, "category", new PropertyEditorSupport() { @Override/*from w w w . j a v a2 s . c om*/ public void setAsText(String text) { if (!text.isEmpty()) { Category category = (Category) categoryService.get(Integer.parseInt(text)); setValue(category); } } }); }
From source file:no.dusken.aranea.admin.control.EditArticleController.java
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); binder.registerCustomEditor(Person.class, "translator", translatorEditor); binder.registerCustomEditor(Issue.class, issueEditor); }
From source file:com.opencart.controller.ProductController.java
@InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(SubCategory.class, "subCategory", new PropertyEditorSupport() { @Override//from w ww. jav a 2s . com public void setAsText(String text) { if (!text.isEmpty()) { SubCategory subCategory = (SubCategory) subCategoryService.getById(Integer.parseInt(text)); setValue(subCategory); } } }); }
From source file:it.univaq.incipict.profilemanager.presentation.AdministrationUserController.java
@InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(Role.class, "roles", new PropertyEditorSupport() { @Override//from w w w. j a v a 2s. c om public void setAsText(String text) { Role role = roleService.findByPK(Long.parseLong(text)); setValue(role); } }); }
From source file:org.jrecruiter.web.controller.BaseFormController.java
/** * Set up a custom property editor for converting form inputs to real objects * @param request the current request/*from ww w. j av a 2s . c o m*/ * @param binder the data binder */ @InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) { binder.registerCustomEditor(Integer.class, null, new CustomNumberEditor(Integer.class, null, true)); binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(Long.class, null, true)); binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor()); SimpleDateFormat dateFormat = new SimpleDateFormat(getText("date.format", request.getLocale())); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateFormat, true)); }
From source file:no.dusken.aranea.admin.control.EditPersonController.java
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); binder.registerCustomEditor(List.class, "roles", rolesEditor); binder.registerCustomEditor(Boolean.class, "showPhoneNumber", booleanEditor); binder.registerCustomEditor(Boolean.class, "showPortrait", booleanEditor); // to actually be able to convert Multipart instance to byte[] // we have to register a custom editor binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor()); binder.setBindEmptyMultipartFiles(false); }
From source file:org.openmrs.module.patientflags.web.FindFlaggedPatientsController.java
@InitBinder public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(Set.class, "tags", new CustomCollectionEditor(Set.class) { @Override/*from w w w. ja v a2 s . c om*/ public Object convertElement(Object element) { return Context.getService(FlagService.class).getTag(Integer.valueOf((String) element)); } }); }
From source file:it.univaq.incipict.profilemanager.presentation.LayoutController.java
@InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(Role.class, "roles", new PropertyEditorSupport() { @Override/*from www .j a v a2 s .c om*/ public void setAsText(String text) { Role role = roleService.findByPK(Long.parseLong(text)); setValue(role); } }); binder.registerCustomEditor(Information.class, "informationSet", new PropertyEditorSupport() { @Override public void setAsText(String text) { Information information = informationService.findByPK(Long.parseLong(text)); setValue(information); } }); }
From source file:org.remus.marketplace.controller.admin.NodeAdminController.java
@Override protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(Set.class, Node.PLATFORMS, new CustomCollectionEditor(Set.class) { @Override//w w w . jav a2 s.c om protected Object convertElement(Object element) { if (element instanceof String) { try { return platformCache.get().get(Integer.parseInt((String) element)); } catch (NumberFormatException e) { return null; } } return null; } // @Override // public void setAsText(String text) // throws IllegalArgumentException { // String[] split = text.split(","); // Set<Platform> platforms = new HashSet<Platform>(); // for (String string : split) { // Platform findById = platformDao.findById(Integer // .valueOf(string)); // platforms.add(findById); // } // setValue(platforms); // } }); }
From source file:org.tonguetied.web.PreferenceController.java
@Override protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(List.class, "selectedLanguages", new CustomCollectionEditor(List.class) { @Override// www . j a v a2 s . c o m protected Object convertElement(Object element) { Language language = null; if (element != null) { Long id = new Long((String) element); language = keywordService.getLanguage(id); } return language; } }); binder.registerCustomEditor(List.class, "selectedCountries", new CustomCollectionEditor(List.class) { @Override protected Object convertElement(Object element) { Country country = null; if (element != null) { Long id = new Long((String) element); country = keywordService.getCountry(id); } return country; } }); binder.registerCustomEditor(List.class, "selectedBundles", new CustomCollectionEditor(List.class) { @Override protected Object convertElement(Object element) { Bundle bundle = null; if (element != null) { Long id = new Long((String) element); bundle = keywordService.getBundle(id); } return bundle; } }); }