Example #1
0
  @SuppressWarnings("unchecked")
  public static <T> T createBean(
      String className, AutowireCapableBeanFactory beanFactory, int autowire) {

    Class<?> beanClass = SpringUtils.classForName(className);
    return (T) beanFactory.createBean(beanClass, autowire, false);
  }
  @SuppressWarnings("unchecked")
  public Object getValue() {
    Collection<Object> collection = null;
    if (getEditorBinding() != null) {
      collection = (Collection<Object>) getEditorBinding().getValue();
    }
    if (collection == null) {
      collection = SpringUtils.newInstance(collectionClass);
    }

    ArrayList<?> oldValues = Generics.newArrayList(collection);
    collection.clear();

    for (Object value : selectedValues) {
      int i = oldValues.indexOf(value);
      if (i >= 0) {
        value = oldValues.get(i);
      }
      collection.add(value);
    }
    return collection;
  }