Examples of BindSimpleHandler


Examples of org.strecks.bind.handler.BindSimpleHandler

    Map<String, BindHandler> bindables = bindConvertInfo.getBindMap();

    BindHandler bh1 = bindables.get("startDate");
    assert null != bh1;

    BindSimpleHandler handler1 = (BindSimpleHandler) bh1;
    assert handler1.getConverter() instanceof DatePatternConverter;
    assert handler1.getConverterClass().equals(DatePatternConverter.class);

    BindHandler bh2 = bindables.get("selectedStartDate");
    assert null != bh2;

    BindSelectHandler selectHandler1 = (BindSelectHandler) bh2;
    assert selectHandler1.getConverter() instanceof DatePatternConverter;
    assert selectHandler1.getConverterClass().equals(DatePatternConverter.class);

    BindHandler bh3 = bindables.get("startDateWithout");
    assert null != bh3;

    BindSimpleHandler handler2 = (BindSimpleHandler) bh3;
    assert handler2.getConverter() != null;
    assert handler2.getConverterClass().equals(SafeBeanUtilsConverter.class);

    BindHandler bh4 = bindables.get("selectedStartDateWithout");
    assert null != bh4;

    BindSelectHandler selectHandler2 = (BindSelectHandler) bh4;
View Full Code Here

Examples of org.strecks.bind.handler.BindSimpleHandler

  public BindHandler createHandler(Annotation annotation, Method getterMethod, Converter converter, ConversionHandler conversionHandler)
  {

    BindSimple bindAnnotation = (BindSimple) annotation;
    BindSimpleHandler handler = new BindSimpleHandler();

    String expression = bindAnnotation.expression();

    String beanLocatingExpression = null;
    String propertyName = null;

    int lastDot = expression.lastIndexOf('.');
    if (lastDot == -1)
    {
      propertyName = expression;
    }
    else
    {
      beanLocatingExpression = expression.substring(0, lastDot);
      propertyName = expression.substring(lastDot + 1);
    }

    handler.setBeanLocatingExpression(beanLocatingExpression);
    handler.setBeanPropertyName(propertyName);

    if (converter != null)
    {
      handler.setConverter(converter);
    }
    else
    {
      Class<? extends Converter> converterClass = bindAnnotation.converter();
      converter = ReflectHelper.createInstance(converterClass, Converter.class);
      handler.setConverter(converter);
    }

    PropertyDescriptor property = BeanUtils.findPropertyForMethod(getterMethod);
    if (property == null)
    {
      throw new ApplicationConfigurationException("Method " + getterMethod + " is not a valid JavaBean property");
    }
    handler.setPropertyDescriptor(property);
    handler.setConversionHandler(conversionHandler);

    return handler;

  }
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.