Package de.fips.util.tinybinding

Examples of de.fips.util.tinybinding.DataBindingContext


    verifyClassAnnotatedWith(formClazz, Form.class);
    Field formField;
    ParameterizedType modelFieldType;
    Class<?> modelFieldInternalType;
    Object formElement;
    DataBindingContext context = new DataBindingContext();
    for (Field modelField : modelClazz.getFields()) {
      // we care for IObservableValues only
      if (!(modelField.getGenericType() instanceof ParameterizedType)) continue;
      modelFieldType = (ParameterizedType) modelField.getGenericType();
      if (!IObservableValue.class.isAssignableFrom((Class<?>) modelFieldType.getRawType())) continue;
      modelFieldInternalType = (Class<?>) modelFieldType.getActualTypeArguments()[0];
      // determine the form representative
      formField = formClazz.getField(modelField.getName());
      boolean accessible = formField.isAccessible();
      try {
        setAccessible(formField, true);
        formElement = formField.get(formObject);
        if (formElement instanceof Container) {
          try {
            Object modelValue = modelField.get(modelObject);
            if (String.class == modelFieldInternalType) {
              IObservableValue<String> value = uncheckedCast(modelValue);
              context.bind(value, observe((Container) formElement).text());
            } else if (Boolean.class == modelFieldInternalType) {
              IObservableValue<Boolean> value = uncheckedCast(modelValue);
              context.bind(value, observe((Container) formElement).selected());
            } else {
              IObservableValue<?> value = (IObservableValue<?>) modelValue;
              context.bind(value, observe((Container) formElement).value());
            }
          } catch(IllegalAccessException e) {
            // can't access model-fields.. no binding.. all good..
          }
        }
View Full Code Here

TOP

Related Classes of de.fips.util.tinybinding.DataBindingContext

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.