List of usage examples for java.beans PropertyEditorSupport PropertyEditorSupport
public PropertyEditorSupport()
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 ww. ja v a 2s . com*/ public void setAsText(String text) { Role role = roleService.findByPK(Long.parseLong(text)); setValue(role); } }); }
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// w w w . ja v a2 s . co m 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:edu.byu.softwareDistribution.web.controller.shopper.ShoppingProductController.java
@InitBinder public void addProductEditor(ServletRequestDataBinder binder) { binder.registerCustomEditor(Product.class, new PropertyEditorSupport() { @Override//from www . ja va 2 s .co m public void setAsText(String text) throws IllegalArgumentException { setValue(productDao.findById(Integer.parseInt(text))); } }); }
From source file:org.remus.marketplace.controller.admin.CategoryAdminController.java
@Override protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(Node.class, new PropertyEditorSupport() { @Override/* ww w. j a va2 s .co m*/ public void setAsText(String text) { Node findById = nodeDao.findById(Integer.parseInt(text)); setValue(findById); } }); }
From source file:nl.surfnet.coin.teams.control.AddTeamController.java
@InitBinder protected void initBinder(ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(Stem.class, "stem", new PropertyEditorSupport() { @Override// w w w. j av a 2 s. com public void setAsText(String text) { Stem stem = new Stem(text, "", ""); setValue(stem); } }); }
From source file:org.openmrs.module.patientflags.web.EditFlagController.java
@InitBinder public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { // map the tag id to the actual tag binder.registerCustomEditor(Set.class, "tags", new CustomCollectionEditor(Set.class) { @Override// ww w . j av a2s .c o m public Object convertElement(Object element) { return Context.getService(FlagService.class).getTag(Integer.valueOf((String) element)); } }); // map the priority id to the actual priority binder.registerCustomEditor(Priority.class, new PropertyEditorSupport() { public void setAsText(String priority) { if (StringUtils.isBlank(priority)) { setValue(null); } else { setValue(Context.getService(FlagService.class).getPriority(Integer.valueOf((String) priority))); } } }); // map the evaluator strings to the full evaluator classes binder.registerCustomEditor(String.class, "evaluator", new PropertyEditorSupport() { public void setAsText(String evaluator) { // check to see if the class is in the evaluator map, if so, set based on the map if (PatientFlagsConstants.FLAG_EVALUATOR_MAP.containsKey(evaluator)) { setValue(PatientFlagsConstants.FLAG_EVALUATOR_MAP.get(evaluator)); } else { // otherwise is must be a custom evaluator; set it directly setValue(evaluator); } } }); }
From source file:com.coul.core.control.action.BaseController.java
/** * ??// w w w. j av a 2 s. co m * 1. ?StringHTML?XSS * 2. Date?String */ @InitBinder protected void initBinder(WebDataBinder binder) { // String??StringHTML?XSS binder.registerCustomEditor(String.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim())); } @Override public String getAsText() { Object value = getValue(); return value != null ? value.toString() : ""; } }); // Date ? binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { //setValue(DateUtils(text)); } }); }
From source file:ru.org.linux.comment.CommentService.java
public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(Topic.class, new PropertyEditorSupport() { @Override/*from w ww .ja v a 2 s . c om*/ public void setAsText(String text) throws IllegalArgumentException { try { setValue(messageDao.getById(Integer.parseInt(text.split(",")[0]))); } catch (MessageNotFoundException e) { throw new IllegalArgumentException(e); } } }); binder.registerCustomEditor(Comment.class, new PropertyEditorSupport() { @Override public void setAsText(String text) throws IllegalArgumentException { if (text.isEmpty() || "0".equals(text)) { setValue(null); return; } try { setValue(commentDao.getById(Integer.parseInt(text))); } catch (MessageNotFoundException e) { throw new IllegalArgumentException(e); } } }); binder.registerCustomEditor(User.class, new UserPropertyEditor(userDao)); }
From source file:com.dcampus.common.web.BaseController.java
/** * ??// w w w. jav a 2s .co m * 1. ?StringHTML?XSS * 2. Date?String */ @InitBinder protected void initBinder(WebDataBinder binder) { // String??StringHTML?XSS binder.registerCustomEditor(String.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim())); } @Override public String getAsText() { Object value = getValue(); return value != null ? value.toString() : ""; } }); // Date ? binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { setValue(DateUtils.parseDate(text)); } }); }
From source file:me.web.CommonController.java
/** * ??/*from w w w .j a v a2s . c o m*/ * 1. ?StringHTML?XSS * 2. Date?String */ @InitBinder protected void initBinder(WebDataBinder binder) { // String??StringHTML?XSS binder.registerCustomEditor(String.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim())); } @Override public String getAsText() { Object value = getValue(); return value != null ? value.toString() : ""; } }); // Date ? binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { try { setValue(DateUtils.parseDate(text)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); }