Package org.strecks.bind.handler

Examples of org.strecks.bind.handler.BindSelectHandler


    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;
    assert selectHandler2.getConverter() instanceof SafeBeanUtilsConverter;
    assert selectHandler2.getConverterClass().equals(SafeBeanUtilsConverter.class);

  }
View Full Code Here


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

    BindSelect bindAnnotation = (BindSelect) annotation;
    BindSelectHandler handler = new BindSelectHandler();

    String expression = bindAnnotation.targetBeanExpression();
    handler.setTargetBeanExpression(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);
    handler.setBeanPropertyClass(bindAnnotation.idClass());
    handler.setBeanLookupExpression(bindAnnotation.lookupMapExpression());
    handler.setBeanPropertyIdName(bindAnnotation.targetBeanIdProperty());

    if (converter != null)
    {
      handler.setConverter(converter);
    }
    else
    {
      Class<? extends Converter> converterClass = bindAnnotation.idConverter();
      converter = ReflectHelper.createInstance(converterClass, Converter.class);
      converter.setTargetClass(bindAnnotation.idClass());
      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

Related Classes of org.strecks.bind.handler.BindSelectHandler

Copyright © 2018 www.massapicom. 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.