Examples of DataBinder


Examples of org.springframework.validation.DataBinder

    protected Object createAttributeFromRequestValue(String sourceValue,
                                                     String attributeName,
                                                     MethodParameter parameter,
                                                     WebDataBinderFactory binderFactory,
                                                     NativeWebRequest request) throws Exception {
        DataBinder binder = binderFactory.createBinder(request, null, attributeName);
        ConversionService conversionService = binder.getConversionService();
        if (conversionService != null) {
            TypeDescriptor source = TypeDescriptor.valueOf(String.class);
            TypeDescriptor target = new TypeDescriptor(parameter);
            if (conversionService.canConvert(source, target)) {
                return binder.convertIfNecessary(sourceValue, parameter.getParameterType(), parameter);
            }
        }
        return null;
    }
View Full Code Here

Examples of org.springframework.validation.DataBinder

    DefaultConversionService.addDefaultConverters(conversionService);
    registrar.registerFormatters(conversionService);

    SimpleDateBean bean = new SimpleDateBean();
    bean.getChildren().add(new SimpleDateBean());
    binder = new DataBinder(bean);
    binder.setConversionService(conversionService);

    LocaleContextHolder.setLocale(Locale.US);
  }
View Full Code Here

Examples of org.springframework.validation.DataBinder

      }
    });
    conversionService.addFormatterForFieldType(Number.class, new NumberFormatter());
    conversionService.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
    LocaleContextHolder.setLocale(Locale.US);
    binder = new DataBinder(new TestBean());
    binder.setConversionService(conversionService);
  }
View Full Code Here

Examples of org.springframework.validation.DataBinder

   */
  protected Object createAttributeFromRequestValue(String sourceValue, String attributeName,
      MethodParameter parameter, WebDataBinderFactory binderFactory, NativeWebRequest request)
      throws Exception {

    DataBinder binder = binderFactory.createBinder(request, null, attributeName);
    ConversionService conversionService = binder.getConversionService();
    if (conversionService != null) {
      TypeDescriptor source = TypeDescriptor.valueOf(String.class);
      TypeDescriptor target = new TypeDescriptor(parameter);
      if (conversionService.canConvert(source, target)) {
        return binder.convertIfNecessary(sourceValue, parameter.getParameterType(), parameter);
      }
    }
    return null;
  }
View Full Code Here

Examples of org.springframework.validation.DataBinder

  @Override
  public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
      NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

    DataBinder dataBinder = binderFactory.createBinder(webRequest, null, null);
    ModelMap redirectAttributes  = new RedirectAttributesModelMap(dataBinder);
    mavContainer.setRedirectModel(redirectAttributes);
    return redirectAttributes;
  }
View Full Code Here

Examples of org.springframework.validation.DataBinder

  }

  public void testBindTagWithIndexedPropertiesAndCustomEditor() throws JspException {
    PageContext pc = createPageContext();
    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new ServletRequestDataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.class, null, new PropertyEditorSupport() {
      @Override
      public String getAsText() {
        return "something";
      }
    });
    Errors errors = binder.getBindingResult();
    errors.rejectValue("array[0]", "code1", "message1");
    errors.rejectValue("array[0]", "code2", "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

    BindTag tag = new BindTag();
View Full Code Here

Examples of org.springframework.validation.DataBinder

    registrar.registerFormatters(conversionService);

    JodaTimeBean bean = new JodaTimeBean();
    bean.getChildren().add(new JodaTimeBean());
    binder = new DataBinder(bean);
    binder.setConversionService(conversionService);

    LocaleContextHolder.setLocale(Locale.US);
    JodaTimeContext context = new JodaTimeContext();
    context.setTimeZone(DateTimeZone.forID("-05:00"));
View Full Code Here

Examples of org.zkoss.zkplus.databind.DataBinder

  private MappingResults bind() {
    final Execution exec = Executions.getCurrent();
    final Component self = ZkFlowContextManager.getSelf(exec);
    if (self != null) {
      final DataBinder binder = (DataBinder) self.getAttributeOrFellow("binder", true);
      if (binder != null) {
        final Collection bindings = binder.getAllBindings();
        if (!bindings.isEmpty()) {
          final RequestContext srcRequestContext =
            ZkFlowContextManager.getFlowRequestContext(exec);
          if (srcRequestContext != null) {
            if (logger.isDebugEnabled()) {
View Full Code Here

Examples of org.zkoss.zkplus.databind.DataBinder

    }

    private static void reloadBindings(boolean forceReload,
            Component... toReload) {
        for (Component reload : toReload) {
            DataBinder binder = Util.getBinder(reload);
            if (binder != null
                    && (forceReload || notReloadedInThisRequest(reload))) {
                binder.loadComponent(reload);
                markAsReloadedForThisRequest(reload);
            }
        }
    }
View Full Code Here

Examples of org.zkoss.zkplus.databind.DataBinder

        return result;
    }

    public static void saveBindings(Component... toReload) {
        for (Component reload : toReload) {
            DataBinder binder = Util.getBinder(reload);
            if (binder != null) {
                binder.saveComponent(reload);
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.