@Override
  public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Exception {
    final String mname = method.getName();
    Class<?> declaringClass = method.getDeclaringClass();
    if (declaringClass.equals(FormFieldCleaner.class)) {
      return super.invoke(self, method, proceed, args);
    } else {
      if ("setFormOwner".equals(mname) || "getFormStatus".equals(mname)) {
        return super.invoke(self, method, proceed, args);
      }

      try {
        if (!method.getDeclaringClass().isAssignableFrom(FormProxyObject.class)) {
          if (mname.startsWith("get")) {
            if (_origin == null) return null;

            final String attr = toAttrName(method);
            if (_cache != null) {
              if (_cache.containsKey(attr)) {
                return _cache.get(attr);
              }
            }

            Object value = method.invoke(_origin, args);
            if (value != null) {

              // ZK-2736 Form proxy with Immutable values
              value = ProxyHelper.createProxyIfAny(value, method.getAnnotations());

              addCache(attr, value);
              if (value instanceof FormProxyObject) {
                addDirtyField(attr); // it may be changed.
              }
            }
            return value;
          }
        }
      } catch (Exception e) {
        throw UiException.Aide.wrap(e);
      }
    }

    return super.invoke(self, method, proceed, args);
  }
Esempio n. 2
0
 public List<E> subList(int fromIndex, int toIndex) {
   return ProxyHelper.createProxyIfAny(
       ((List<E>) getCache()).subList(fromIndex, toIndex), _callerAnnots);
 }