@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");
    }
  }
Exemplo n.º 2
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());
  }