@InitBinder
 public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws Exception {
   binder.registerCustomEditor(PatientIdentifierType.class, new PatientIdentifierTypeEditor());
   binder.registerCustomEditor(IdentifierSource.class, new IdentifierSourceEditor());
   binder.registerCustomEditor(AutoGenerationOption.class, new AutoGenerationOptionEditor());
 }
 /** OverRiding generic implementation to register Communication Method Enumerations */
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
   super.initBinder(request, binder);
   binder.registerCustomEditor(
       CommunicationMethodEnumeration.class,
       new FoursoftEnumerationPropertyEditor(new CommunicationMethodEnumeration()));
   binder.registerCustomEditor(
       ActiveInactiveStatusEnumeration.class,
       new FoursoftEnumerationPropertyEditor(new ActiveInactiveStatusEnumeration()));
 }
  @Override
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
      throws Exception {

    super.initBinder(request, binder);

    binder.registerCustomEditor(Date.class, new DateEditor());
    binder.registerCustomEditor(NestedWidgets.class, new NestedWidgetsEditor());
  }
Ejemplo n.º 4
0
  @InitBinder
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
      throws Exception {

    binder.registerCustomEditor(int.class, new IntegerEditor());
    binder.registerCustomEditor(long.class, new LongEditor());
    binder.registerCustomEditor(double.class, new DoubleEditor());
    binder.registerCustomEditor(Date.class, new DateEditor());
  }
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
    super.initBinder(request, binder);

    ReferencePropertyEditor ed4 = new ReferencePropertyEditor();
    CheckboxPropertyEditor chkEd = new CheckboxPropertyEditor();
    ed4.setReferenceManager(this.referenceManager);
    binder.registerCustomEditor(Reference.class, "region", ed4);
    binder.registerCustomEditor(Boolean.class, null, chkEd);
  }
Ejemplo n.º 6
0
 @Override
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws Exception {
   super.initBinder(request, binder);
   // NumberFormat nf = NumberFormat.getInstance(new Locale("en_US"));
   binder.registerCustomEditor(
       java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
   binder.registerCustomEditor(EncounterType.class, new EncounterTypeEditor());
 }
Ejemplo n.º 7
0
  @InitBinder
  public void initBinder(ServletRequestDataBinder binder) {
    /** 自动转换日期类型的字段格式 */
    binder.registerCustomEditor(
        Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true));

    /** 防止XSS攻击 */
    binder.registerCustomEditor(String.class, new StringEscapeEditor(true, false));
  }
Ejemplo n.º 8
0
 @Override
 public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws Exception {
   // enable null values for long and float fields
   NumberFormat nf = NumberFormat.getInstance(request.getLocale());
   binder.registerCustomEditor(
       java.lang.Long.class, new CustomNumberEditor(java.lang.Long.class, nf, true));
   binder.registerCustomEditor(
       java.lang.Float.class, new CustomNumberEditor(java.lang.Float.class, nf, true));
 }
 /**
  * Set up a custom property editor for converting form inputs to real objects
  *
  * @param request the current request
  * @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));
 }
 @InitBinder
 public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws Exception {
   SimpleDateFormat dateFormat = Context.getDateFormat();
   dateFormat.setLenient(false);
   binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true, 10));
   binder.registerCustomEditor(Concept.class, new ConceptEditor());
   binder.registerCustomEditor(Patient.class, new PatientEditor());
   binder.registerCustomEditor(Encounter.class, new EncounterEditor());
 }
Ejemplo n.º 11
0
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
      throws Exception {
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm");
    CustomDateEditor editor = new CustomDateEditor(dateFormat, true);

    SimpleDateFormat dateFormat1 = new SimpleDateFormat("dd-MM-yyyy");
    CustomDateEditor editor1 = new CustomDateEditor(dateFormat1, true);

    binder.registerCustomEditor(Date.class, "inspectionDate", editor);
    binder.registerCustomEditor(Date.class, "issueDate", editor1);
  }
  /**
   * Allows for Integers to be used as values in input tags. Normally, only strings and lists are
   * expected
   *
   * @see
   *     org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest,
   *     org.springframework.web.bind.ServletRequestDataBinder)
   */
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
      throws Exception {
    super.initBinder(request, binder);

    Locale locale = Context.getLocale();
    NumberFormat nf = NumberFormat.getInstance(locale);

    // NumberFormat nf = NumberFormat.getInstance(new Locale("en_US"));
    binder.registerCustomEditor(
        java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, nf, true));
    binder.registerCustomEditor(
        java.util.Date.class, new CustomDateEditor(Context.getDateFormat(), true, 10));
  }
 /**
  * Bind request parameters onto the given command bean
  *
  * @param request request from which parameters will be bound
  * @param command command object, that must be a JavaBean
  * @throws Exception in case of invalid state or arguments
  */
 protected void bind(ServletRequest request, Object command) throws Exception {
   logger.debug("Binding request parameters onto MultiActionController command");
   ServletRequestDataBinder binder = createBinder(request, command);
   binder.bind(request);
   if (this.validators != null) {
     for (int i = 0; i < this.validators.length; i++) {
       if (this.validators[i].supports(command.getClass())) {
         ValidationUtils.invokeValidator(this.validators[i], command, binder.getErrors());
       }
     }
   }
   binder.closeNoCatch();
 }
  @Override
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
      throws Exception {
    super.initBinder(request, binder);
    // 注册自定义的属性编辑器
    // 1、日期
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    CustomDateEditor dateEditor = new CustomDateEditor(df, true);
    // 表示如果命令对象有Date类型的属性,将使用该属性编辑器进行类型转换
    binder.registerCustomEditor(Date.class, dateEditor);

    // 自定义的电话号码编辑器
    binder.registerCustomEditor(PhoneNumberModel.class, new PhoneNumberEditor());
  }
Ejemplo n.º 15
0
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws ServletException {
   // to actually be able to convert Multipart instance to byte[]
   // we have to register a custom editor
   binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
   // now Spring knows how to handle multipart object and convert them
 }
Ejemplo n.º 16
0
 /**
  * @MethodName: initBinder @Description: 对绑定的时间进行格式化处理
  *
  * @param request
  * @param binder
  * @throws Exception
  * @author WangJuZhu
  */
 @InitBinder
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws Exception {
   DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
   CustomDateEditor dateEditor = new CustomDateEditor(fmt, true);
   binder.registerCustomEditor(Date.class, dateEditor);
 }
 @Override
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws Exception {
   // super.initBinder(request, binder);
   binder.registerCustomEditor(
       Date.class, new CustomDateEditor(new SimpleDateFormat("MM/dd"), false));
 }
  @Override
  protected void bind(HttpServletRequest request, Object command) throws Exception {
    if (logger.isDebugEnabled()) {
      logger.debug("bind(HttpServletRequest, Object) - start");
    }

    // TODO Auto-generated method stub

    ServletRequestDataBinder binder = createBinder(request, command);
    binder.bind(request);
    errors = binder.getBindingResult();

    if (logger.isDebugEnabled()) {
      logger.debug("bind(HttpServletRequest, Object) - end");
    }
  }
Ejemplo n.º 19
0
  @Override
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
      throws Exception {

    binder.registerCustomEditor(
        Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-mm-dd"), true));
  }
 /**
  * {@inheritDoc} Sets the require fields and the disallowed fields from the HttpServletRequest.
  *
  * @see
  *     org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest,
  *     org.springframework.web.bind.ServletRequestDataBinder)
  */
 @Override
 protected void initBinder(final HttpServletRequest request, final ServletRequestDataBinder binder)
     throws Exception {
   binder.setRequiredFields(
       new String[] {
         "description",
         "serviceId",
         "name",
         "allowedToProxy",
         "enabled",
         "ssoEnabled",
         "anonymousAccess",
         "evaluationOrder"
       });
   binder.setDisallowedFields(new String[] {"id"});
   binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
 }
Ejemplo n.º 21
0
 public void bind(PropertyValues propertyValues, String prefix) {
   PropertyValues values = filterPropertyValues(propertyValues, prefix);
   if (propertyValues instanceof MutablePropertyValues) {
     MutablePropertyValues mutablePropertyValues = (MutablePropertyValues) propertyValues;
     preProcessMutablePropertyValues(mutablePropertyValues);
   }
   super.bind(values);
 }
Ejemplo n.º 22
0
 /**
  * 将前台传递过来的日期格式的字符串,自动转化为Date类型
  *
  * @param binder
  */
 @InitBinder
 public void initBinder(ServletRequestDataBinder binder) {
   //		SimpleDateFormat dateFormat = new SimpleDateFormat(
   //				"yyyy-MM-dd hh:mm:ss");
   //		binder.registerCustomEditor(Date.class, new CustomDateEditor(
   //				dateFormat, true));
   binder.registerCustomEditor(Date.class, new DateConvertEditor());
 }
Ejemplo n.º 23
0
  public void testValidateCompositeField_InvalidValue() throws Exception {
    ParticipantHistory history = new ParticipantHistory();
    history.getWeight().setQuantity(-99.0);

    InputField textField =
        InputFieldFactory.createTextField("quantity", "", new DecimalRangeValidator(1, 999));
    group.addField(textField);

    field = new CompositeField("weight", group);

    ServletRequestDataBinder binder = new ServletRequestDataBinder(history, "history");
    BindException errors = new BindException(binder.getBindingResult());

    field.validate(new BeanWrapperImpl(history), errors);
    System.out.println(errors);
    assertTrue(errors.hasErrors());
  }
Ejemplo n.º 24
0
 @Override
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws Exception {
   binder.registerCustomEditor(
       List.class,
       "selectedLanguages",
       new CustomCollectionEditor(List.class) {
         @Override
         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;
         }
       });
 }
 @InitBinder
 protected void initBinder(
     final HttpServletRequest request, final ServletRequestDataBinder binder) {
   final DateFormat dateFormat =
       new SimpleDateFormat(
           getMessageSource()
               .getMessage("text.store.dateformat", null, getI18nService().getCurrentLocale()));
   final CustomDateEditor editor = new CustomDateEditor(dateFormat, true);
   binder.registerCustomEditor(Date.class, editor);
 }
Ejemplo n.º 26
0
  @Override
  @SuppressWarnings("unchecked")
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
      throws Exception {
    super.initBinder(request, binder);

    ConfigurationProperty configurationProperty = configuration.getProperties().get("skinPath");
    binder.registerCustomEditor(
        Object.class,
        "conf[" + configurationProperty.getKey() + "].value",
        new ConfigurationPropertyEditor(configurationProperty));
  }
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
   Hashtable appSettings =
       (Hashtable) request.getSession().getServletContext().getAttribute("appSettings");
   if (request.getSession(false) != null
       && appSettings.containsKey(request.getSession(false).getId())) {
     java.text.DateFormat dtFormat = getDateFromatObject(request);
     CustomDateEditor cde = new CustomDateEditor(dtFormat, true);
     binder.registerCustomEditor(java.util.Date.class, cde);
     CustomBooleanEditor cbe =
         new CustomBooleanEditor(
             CustomBooleanEditor.VALUE_YES, CustomBooleanEditor.VALUE_NO, true);
     binder.registerCustomEditor(Boolean.class, cbe);
     FoursoftBigDecimalPropertyEditor bde =
         new FoursoftBigDecimalPropertyEditor(getUserLocale(request));
     binder.registerCustomEditor(BigDecimal.class, bde);
     StringTrimmerEditor ste =
         new StringTrimmerEditor(true); // empty strings will be treated as null.
     binder.registerCustomEditor(String.class, ste);
     DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(getUserLocale(request));
     df.applyLocalizedPattern("0.0");
     CustomNumberEditor cint =
         new CustomNumberEditor(
             Integer.class, NumberFormat.getInstance(getUserLocale(request)), true);
     binder.registerCustomEditor(Integer.class, cint);
     CustomNumberEditor clong =
         new CustomNumberEditor(
             Long.class, NumberFormat.getInstance(getUserLocale(request)), true);
     binder.registerCustomEditor(Long.class, clong);
   }
 }
Ejemplo n.º 28
0
 @InitBinder
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     throws Exception {
   binder.registerCustomEditor(
       VatRate.class,
       "vatRate",
       new PropertyEditorSupport() {
         @Override
         public void setAsText(String text) {
           VatRate vatRate = vatRateService.getVatRateById(Integer.parseInt(text));
           setValue(vatRate);
         }
       });
 }
  @InitBinder
  protected void initBinder(final HttpServletRequest request, final ServletRequestDataBinder binder)
      throws Exception {
    binder.registerCustomEditor(
        Usuario.class,
        "usuario",
        new PropertyEditorSupport() {
          @Override
          public void setAsText(final String id) {
            Usuario usuario = usuarioService.buscaUsuario(Long.parseLong(id));
            setValue(usuario);
          }
        });

    binder.registerCustomEditor(
        Date.class, new CustomDateEditor(new SimpleDateFormat("dd/mm/yy"), false));

    binder.registerCustomEditor(
        Fornecedor.class,
        "fornecedor",
        new PropertyEditorSupport() {
          @Override
          public void setAsText(final String id) {
            Fornecedor fornecedor = fornecedorService.getFornecedor(Long.parseLong(id));
            setValue(fornecedor);
          }
        });

    binder.registerCustomEditor(
        Fornecedor.class,
        new PropertyEditorSupport() {
          @Override
          public void setAsText(final String id) {
            Fornecedor fornecedor = fornecedorService.getFornecedor(Long.parseLong(id));
            setValue(fornecedor);
          }
        });

    binder.registerCustomEditor(
        Predio.class,
        new PropertyEditorSupport() {
          @Override
          public void setAsText(final String id) {
            Predio predio = predioService.getPredio(Long.parseLong(id));
            setValue(predio);
          }
        });
    binder.registerCustomEditor(
        Cotacao.class,
        new PropertyEditorSupport() {
          @Override
          public void setAsText(final String id) {
            Cotacao cotacao = service.getCotacao(Long.parseLong(id));
            setValue(cotacao);
          }
        });
  }
  /**
   * Allows for Integers to be used as values in input tags. Normally, only strings and lists are
   * expected
   *
   * @see
   *     org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest,
   *     org.springframework.web.bind.ServletRequestDataBinder)
   */
  @Override
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
      throws Exception {
    super.initBinder(request, binder);

    binder.registerCustomEditor(
        java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
    binder.registerCustomEditor(
        java.util.Date.class, new CustomDateEditor(Context.getDateTimeFormat(), true));
    binder.registerCustomEditor(EncounterType.class, new EncounterTypeEditor());
    binder.registerCustomEditor(Location.class, new LocationEditor());
    binder.registerCustomEditor(Form.class, new FormEditor());
    binder.registerCustomEditor(Visit.class, new VisitEditor());
  }