The Unified and Autonomous Development Platform
Complete bean editor.
robin shinec1bce23af2da
diff --git a/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/Bootstrap.java b/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/Bootstrap.javaindex 9eebc81cfa..135d1036e0 100644--- a/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/Bootstrap.java+++ b/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/Bootstrap.java@@ -11,6 +11,7 @@ import java.util.Comparator;import java.util.List;import java.util.Map;import java.util.Set;+import java.util.concurrent.ConcurrentHashMap;import java.util.logging.Handler;import org.slf4j.Logger;@@ -172,6 +173,8 @@ public class Bootstrap {ClassLoader appClassLoader = new URLClassLoader(urls.toArray(new URL[0]), Bootstrap.class.getClassLoader()) {+ private Map<String, CachedUrl> resourceCache = new ConcurrentHashMap<String, CachedUrl>();+@Overrideprotected Class<?> findClass(String name) throws ClassNotFoundException {return super.findClass(name);@@ -184,7 +187,15 @@ public class Bootstrap {@Overridepublic URL findResource(String name) {- return super.findResource(name);+ URL url;+ CachedUrl cachedUrl = resourceCache.get(name);+ if (cachedUrl == null) {+ url = super.findResource(name);+ resourceCache.put(name, new CachedUrl(url));+ } else {+ url = cachedUrl.getUrl();+ }+ return url;}};@@ -266,4 +277,15 @@ public class Bootstrap {return new File(installDir, "conf");}+ private static class CachedUrl {+ private final URL url;++ public CachedUrl(URL url) {+ this.url = url;+ }++ public URL getUrl() {+ return url;+ }+ }}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractEditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractEditContext.javaindex d8a6e0e466..8e4b560176 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractEditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractEditContext.java@@ -9,7 +9,7 @@ import java.util.Map;import com.pmease.commons.util.GeneralException;@SuppressWarnings("serial")-public abstract class AbstractEditContext<T> implements EditContext<T> {+public abstract class AbstractEditContext implements EditContext {protected List<String> validationErrorMessages = new ArrayList<String>();@@ -31,7 +31,7 @@ public abstract class AbstractEditContext<T> implements EditContext<T> {}if (recursive && getChildContexts() != null) {- for (Map.Entry<Serializable, EditContext<T>> eachEntry: getChildContexts().entrySet()) {+ for (Map.Entry<Serializable, EditContext> eachEntry: getChildContexts().entrySet()) {for (ValidationError eachError: eachEntry.getValue().getValidationErrors(true)) {PropertyPath newPath = eachError.getPropertyPath().prepend(eachEntry.getKey());validationErrors.add(new ValidationError(newPath, eachError.getErrorMessage()));@@ -45,7 +45,7 @@ public abstract class AbstractEditContext<T> implements EditContext<T> {public void validate() {validationErrorMessages.clear();if (getChildContexts() != null) {- for (EditContext<T> each: getChildContexts().values())+ for (EditContext each: getChildContexts().values())each.validate();}@@ -60,9 +60,9 @@ public abstract class AbstractEditContext<T> implements EditContext<T> {}@Override- public EditContext<T> getChildContext(Serializable propertyName) {+ public EditContext getChildContext(Serializable propertyName) {if (getChildContexts() != null) {- EditContext<T> childContext = getChildContexts().get(propertyName);+ EditContext childContext = getChildContexts().get(propertyName);if (childContext != null)return childContext;}@@ -72,7 +72,7 @@ public abstract class AbstractEditContext<T> implements EditContext<T> {@Overridepublic boolean hasError(Serializable propertyName, boolean recursive) {- EditContext<T> childContext = getChildContext(propertyName);+ EditContext childContext = getChildContext(propertyName);return !childContext.getValidationErrors(recursive).isEmpty();}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractListEditSupport.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractListEditSupport.javaindex 50b8f95416..464b680fdd 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractListEditSupport.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractListEditSupport.java@@ -8,15 +8,15 @@ import com.pmease.commons.editable.annotation.Editable;import com.pmease.commons.util.BeanUtils;import com.pmease.commons.util.ClassUtils;-public abstract class AbstractListEditSupport<T> implements EditSupport<T> {+public abstract class AbstractListEditSupport implements EditSupport {@Override- public BeanEditContext<T> getBeanEditContext(Serializable bean) {+ public BeanEditContext getBeanEditContext(Serializable bean) {return null;}@Override- public PropertyEditContext<T> getPropertyEditContext(Serializable bean, String propertyName) {+ public PropertyEditContext getPropertyEditContext(Serializable bean, String propertyName) {Method propertyGetter = BeanUtils.getGetter(bean.getClass(), propertyName);if (propertyGetter.getReturnType() == List.class) {Class<?> elementClass = EditableUtils.getElementClass(propertyGetter.getGenericReturnType());@@ -33,7 +33,7 @@ public abstract class AbstractListEditSupport<T> implements EditSupport<T> {return null;}- protected abstract AbstractPolymorphicListPropertyEditContext<T> newPolymorphicListEditContext(Serializable bean, String propertyName);+ protected abstract AbstractPolymorphicListPropertyEditContext newPolymorphicListEditContext(Serializable bean, String propertyName);- protected abstract AbstractTableListPropertyEditContext<T> newTableListEditContext(Serializable bean, String propertyName);+ protected abstract AbstractTableListPropertyEditContext newTableListEditContext(Serializable bean, String propertyName);}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicEditSupport.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicEditSupport.javaindex 2927dcb884..25d2b5b829 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicEditSupport.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicEditSupport.java@@ -7,15 +7,15 @@ import com.pmease.commons.editable.annotation.Editable;import com.pmease.commons.util.BeanUtils;import com.pmease.commons.util.ClassUtils;-public abstract class AbstractPolymorphicEditSupport<T> implements EditSupport<T> {+public abstract class AbstractPolymorphicEditSupport implements EditSupport {@Override- public BeanEditContext<T> getBeanEditContext(Serializable bean) {+ public BeanEditContext getBeanEditContext(Serializable bean) {return null;}@Override- public PropertyEditContext<T> getPropertyEditContext(Serializable bean, String propertyName) {+ public PropertyEditContext getPropertyEditContext(Serializable bean, String propertyName) {Method propertyGetter = BeanUtils.getGetter(bean.getClass(), propertyName);Class<?> propertyClass = propertyGetter.getReturnType();if (propertyClass.getAnnotation(Editable.class) != null@@ -26,6 +26,6 @@ public abstract class AbstractPolymorphicEditSupport<T> implements EditSupport<T}}- protected abstract AbstractPolymorphicPropertyEditContext<T> newPolymorphicPropertyEditContext(Serializable bean, String propertyName);+ protected abstract AbstractPolymorphicPropertyEditContext newPolymorphicPropertyEditContext(Serializable bean, String propertyName);}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicListPropertyEditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicListPropertyEditContext.javaindex d3f3c0a8a0..b112a3dadd 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicListPropertyEditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicListPropertyEditContext.java@@ -11,16 +11,18 @@ import com.pmease.commons.loader.AppLoader;import com.pmease.commons.loader.ImplementationRegistry;@SuppressWarnings("serial")-public abstract class AbstractPolymorphicListPropertyEditContext<T> extends PropertyEditContext<T> {+public abstract class AbstractPolymorphicListPropertyEditContext extends PropertyEditContext {private final List<Class<?>> implementations = new ArrayList<Class<?>>();- private List<BeanEditContext<T>> elementContexts;+ private List<BeanEditContext> elementContexts;public AbstractPolymorphicListPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);- Class<?> elementBaseClass = getPropertyGetter().getReturnType();+ Class<?> elementBaseClass = EditableUtils.getElementClass(getPropertyGetter().getGenericReturnType());+ Preconditions.checkNotNull(elementBaseClass);+ImplementationRegistry registry = AppLoader.getInstance(ImplementationRegistry.class);implementations.addAll(registry.getImplementations(elementBaseClass));@@ -33,11 +35,10 @@ public abstract class AbstractPolymorphicListPropertyEditContext<T> extends ProppropertyValueChanged(getPropertyValue());}- @SuppressWarnings("unchecked")protected void propertyValueChanged(Serializable propertyValue) {if (propertyValue != null) {EditSupportRegistry registry = AppLoader.getInstance(EditSupportRegistry.class);- elementContexts = new ArrayList<BeanEditContext<T>>();+ elementContexts = new ArrayList<BeanEditContext>();for (Serializable element: getPropertyValue()) {elementContexts.add(registry.getBeanEditContext(element));}@@ -45,6 +46,10 @@ public abstract class AbstractPolymorphicListPropertyEditContext<T> extends PropelementContexts = null;}}++ public List<Class<?>> getImplementations() {+ return implementations;+ }@Overridepublic void setPropertyValue(Serializable propertyValue) {@@ -52,7 +57,7 @@ public abstract class AbstractPolymorphicListPropertyEditContext<T> extends ProppropertyValueChanged(propertyValue);}- public List<BeanEditContext<T>> getElementContexts() {+ public List<BeanEditContext> getElementContexts() {return elementContexts;}@@ -62,7 +67,6 @@ public abstract class AbstractPolymorphicListPropertyEditContext<T> extends Propreturn (ArrayList<Serializable>) super.getPropertyValue();}- @SuppressWarnings("unchecked")public void addElement(int index, Serializable element) {List<Serializable> propertyValue = getPropertyValue();Preconditions.checkNotNull(propertyValue);@@ -80,8 +84,8 @@ public abstract class AbstractPolymorphicListPropertyEditContext<T> extends Prop}@Override- public Map<Serializable, EditContext<T>> getChildContexts() {- Map<Serializable, EditContext<T>> childContexts = new LinkedHashMap<Serializable, EditContext<T>>();+ public Map<Serializable, EditContext> getChildContexts() {+ Map<Serializable, EditContext> childContexts = new LinkedHashMap<Serializable, EditContext>();if (elementContexts != null) {for (int i=0; i<elementContexts.size(); i++)childContexts.put(i, elementContexts.get(i));diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicPropertyEditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicPropertyEditContext.javaindex 1c585dd8c3..434080fe46 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicPropertyEditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractPolymorphicPropertyEditContext.java@@ -10,11 +10,11 @@ import com.pmease.commons.loader.AppLoader;import com.pmease.commons.loader.ImplementationRegistry;@SuppressWarnings("serial")-public abstract class AbstractPolymorphicPropertyEditContext<T> extends PropertyEditContext<T> {+public abstract class AbstractPolymorphicPropertyEditContext extends PropertyEditContext {private final List<Class<?>> implementations = new ArrayList<Class<?>>();- private BeanEditContext<T> valueContext;+ private BeanEditContext valueContext;public AbstractPolymorphicPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);@@ -36,7 +36,6 @@ public abstract class AbstractPolymorphicPropertyEditContext<T> extends Propertyreturn implementations;}- @SuppressWarnings("unchecked")protected void propertyValueChanged(Serializable propertyValue) {if (propertyValue != null) {EditSupportRegistry registry = AppLoader.getInstance(EditSupportRegistry.class);@@ -53,19 +52,18 @@ public abstract class AbstractPolymorphicPropertyEditContext<T> extends PropertypropertyValueChanged(propertyValue);}- public BeanEditContext<T> getValueContext() {+ public BeanEditContext getValueContext() {return valueContext;}@Override- public Map<Serializable, EditContext<T>> getChildContexts() {+ public Map<Serializable, EditContext> getChildContexts() {if (valueContext != null)return valueContext.getChildContexts();elsereturn null;}- @SuppressWarnings("unchecked")@Overrideprotected void doValidation() {super.doValidation();@@ -73,7 +71,7 @@ public abstract class AbstractPolymorphicPropertyEditContext<T> extends Property// redirect error message of bean level of the property value to be directly// under this propertyif (valueContext != null && valueContext.getBean() instanceof Validatable) {- ((Validatable<T>)valueContext.getBean()).validate(this);+ ((Validatable)valueContext.getBean()).validate(this);}}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionBeanEditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionBeanEditContext.javaindex 94302fab6a..7e47d9242b 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionBeanEditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionBeanEditContext.java@@ -12,11 +12,10 @@ import com.pmease.commons.loader.AppLoader;import com.pmease.commons.util.BeanUtils;@SuppressWarnings("serial")-public abstract class AbstractReflectionBeanEditContext<T> extends BeanEditContext<T> {+public abstract class AbstractReflectionBeanEditContext extends BeanEditContext {- private List<PropertyEditContext<T>> propertyContexts = new ArrayList<PropertyEditContext<T>>();+ private List<PropertyEditContext> propertyContexts = new ArrayList<PropertyEditContext>();- @SuppressWarnings("unchecked")public AbstractReflectionBeanEditContext(Serializable bean) {super(bean);@@ -31,14 +30,14 @@ public abstract class AbstractReflectionBeanEditContext<T> extends BeanEditConte}}- public List<PropertyEditContext<T>> getPropertyContexts() {+ public List<PropertyEditContext> getPropertyContexts() {return propertyContexts;}@Override- public Map<Serializable, EditContext<T>> getChildContexts() {- Map<Serializable, EditContext<T>> childContexts = new LinkedHashMap<Serializable, EditContext<T>>();- for (PropertyEditContext<T> each: propertyContexts) {+ public Map<Serializable, EditContext> getChildContexts() {+ Map<Serializable, EditContext> childContexts = new LinkedHashMap<Serializable, EditContext>();+ for (PropertyEditContext each: propertyContexts) {childContexts.put(each.getPropertyName(), each);}return childContexts;diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionEditSupport.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionEditSupport.javaindex 96cf184f32..d7790fdf32 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionEditSupport.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionEditSupport.java@@ -7,10 +7,10 @@ import com.pmease.commons.editable.annotation.Editable;import com.pmease.commons.util.BeanUtils;import com.pmease.commons.util.ClassUtils;-public abstract class AbstractReflectionEditSupport<T> implements EditSupport<T> {+public abstract class AbstractReflectionEditSupport implements EditSupport {@Override- public BeanEditContext<T> getBeanEditContext(Serializable bean) {+ public BeanEditContext getBeanEditContext(Serializable bean) {if (bean.getClass().getAnnotation(Editable.class) != null && ClassUtils.isConcrete(bean.getClass()))return newReflectionBeanEditContext(bean);else@@ -18,7 +18,7 @@ public abstract class AbstractReflectionEditSupport<T> implements EditSupport<T>}@Override- public PropertyEditContext<T> getPropertyEditContext(Serializable bean, String propertyName) {+ public PropertyEditContext getPropertyEditContext(Serializable bean, String propertyName) {Method propertyGetter = BeanUtils.getGetter(bean.getClass(), propertyName);Class<?> propertyClass = propertyGetter.getReturnType();if (propertyClass.getAnnotation(Editable.class) != null && ClassUtils.isConcrete(propertyClass)) {@@ -28,8 +28,8 @@ public abstract class AbstractReflectionEditSupport<T> implements EditSupport<T>}}- protected abstract AbstractReflectionBeanEditContext<T> newReflectionBeanEditContext(Serializable bean);+ protected abstract AbstractReflectionBeanEditContext newReflectionBeanEditContext(Serializable bean);- protected abstract AbstractReflectionPropertyEditContext<T> newReflectionPropertyEditContext(Serializable bean, String propertyName);+ protected abstract AbstractReflectionPropertyEditContext newReflectionPropertyEditContext(Serializable bean, String propertyName);}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionPropertyEditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionPropertyEditContext.javaindex 1841b0898a..3bb1c378a0 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionPropertyEditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractReflectionPropertyEditContext.java@@ -6,9 +6,9 @@ import java.util.Map;import com.pmease.commons.loader.AppLoader;@SuppressWarnings("serial")-public abstract class AbstractReflectionPropertyEditContext<T> extends PropertyEditContext<T> {+public abstract class AbstractReflectionPropertyEditContext extends PropertyEditContext {- private BeanEditContext<T> valueContext;+ private BeanEditContext valueContext;public AbstractReflectionPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);@@ -16,11 +16,10 @@ public abstract class AbstractReflectionPropertyEditContext<T> extends PropertyEpropertyValueChanged(getPropertyValue());}- public BeanEditContext<T> getValueContext() {+ public BeanEditContext getValueContext() {return valueContext;}- @SuppressWarnings("unchecked")protected void propertyValueChanged(Serializable propertyValue) {if (propertyValue != null) {EditSupportRegistry registry = AppLoader.getInstance(EditSupportRegistry.class);@@ -38,14 +37,13 @@ public abstract class AbstractReflectionPropertyEditContext<T> extends PropertyE}@Override- public Map<Serializable, EditContext<T>> getChildContexts() {+ public Map<Serializable, EditContext> getChildContexts() {if (valueContext != null)return valueContext.getChildContexts();elsereturn null;}- @SuppressWarnings("unchecked")@Overrideprotected void doValidation() {super.doValidation();@@ -53,7 +51,7 @@ public abstract class AbstractReflectionPropertyEditContext<T> extends PropertyE// redirect error message of bean level of the property value to be directly// under this propertyif (valueContext != null && valueContext.getBean() instanceof Validatable) {- ((Validatable<T>)valueContext.getBean()).validate(this);+ ((Validatable)valueContext.getBean()).validate(this);}}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractTableListPropertyEditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractTableListPropertyEditContext.javaindex 4425ad6f48..bd724bf2dc 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/AbstractTableListPropertyEditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/AbstractTableListPropertyEditContext.java@@ -15,11 +15,11 @@ import com.pmease.commons.loader.AppLoader;import com.pmease.commons.util.BeanUtils;@SuppressWarnings("serial")-public abstract class AbstractTableListPropertyEditContext<T> extends PropertyEditContext<T> {+public abstract class AbstractTableListPropertyEditContext extends PropertyEditContext {private Class<?> elementClass;- private List<List<PropertyEditContext<T>>> elementContexts;+ private List<List<PropertyEditContext>> elementContexts;private transient List<Method> elementPropertyGetters;@@ -52,7 +52,7 @@ public abstract class AbstractTableListPropertyEditContext<T> extends PropertyEdprotected void propertyValueChanged(Serializable propertyValue) {if (propertyValue != null) {- elementContexts = new ArrayList<List<PropertyEditContext<T>>>();+ elementContexts = new ArrayList<List<PropertyEditContext>>();for (Serializable element: getPropertyValue()) {elementContexts.add(createElementPropertyContexts(element));}@@ -67,14 +67,13 @@ public abstract class AbstractTableListPropertyEditContext<T> extends PropertyEdpropertyValueChanged(propertyValue);}- public List<List<PropertyEditContext<T>>> getElementContexts() {+ public List<List<PropertyEditContext>> getElementContexts() {return elementContexts;}- @SuppressWarnings("unchecked")- private List<PropertyEditContext<T>> createElementPropertyContexts(Serializable element) {+ private List<PropertyEditContext> createElementPropertyContexts(Serializable element) {EditSupportRegistry registry = AppLoader.getInstance(EditSupportRegistry.class);- List<PropertyEditContext<T>> propertyContexts = new ArrayList<PropertyEditContext<T>>();+ List<PropertyEditContext> propertyContexts = new ArrayList<PropertyEditContext>();for (Method elementPropertyGetter: getElementPropertyGetters()) {String elementPropertyName = BeanUtils.getPropertyName(elementPropertyGetter);propertyContexts.add(registry.getPropertyEditContext(element, elementPropertyName));@@ -104,30 +103,30 @@ public abstract class AbstractTableListPropertyEditContext<T> extends PropertyEd}@Override- public Map<Serializable, EditContext<T>> getChildContexts() {- Map<Serializable, EditContext<T>> childContexts = new LinkedHashMap<Serializable, EditContext<T>>();+ public Map<Serializable, EditContext> getChildContexts() {+ Map<Serializable, EditContext> childContexts = new LinkedHashMap<Serializable, EditContext>();if (elementContexts != null) {for (int i=0; i<elementContexts.size(); i++) {final String errorMessagePrefix = "row " + (i+1) + ": ";- final List<PropertyEditContext<T>> elementPropertyContexts = elementContexts.get(i);+ final List<PropertyEditContext> elementPropertyContexts = elementContexts.get(i);- EditContext<T> elementContext = new AbstractEditContext<T>(getPropertyValue().get(i)) {+ EditContext elementContext = new AbstractEditContext(getPropertyValue().get(i)) {@Override- public Map<Serializable, EditContext<T>> getChildContexts() {- Map<Serializable, EditContext<T>> childContexts = new LinkedHashMap<Serializable, EditContext<T>>();- for (PropertyEditContext<T> each: elementPropertyContexts)+ public Map<Serializable, EditContext> getChildContexts() {+ Map<Serializable, EditContext> childContexts = new LinkedHashMap<Serializable, EditContext>();+ for (PropertyEditContext each: elementPropertyContexts)childContexts.put(each.getPropertyName(), each);return childContexts;}@Override- public void renderForEdit(T renderContext) {+ public Object renderForEdit(Object renderParam) {throw new UnsupportedOperationException();}@Override- public void renderForView(T renderContext) {+ public Object renderForView(Object renderParam) {throw new UnsupportedOperationException();}@@ -140,7 +139,7 @@ public abstract class AbstractTableListPropertyEditContext<T> extends PropertyEd}if (recursive) {- for (Map.Entry<Serializable, EditContext<T>> eachEntry: getChildContexts().entrySet()) {+ for (Map.Entry<Serializable, EditContext> eachEntry: getChildContexts().entrySet()) {for (ValidationError eachError: eachEntry.getValue().getValidationErrors(true)) {PropertyPath newPath = eachError.getPropertyPath().prepend(eachEntry.getKey());validationErrors.add(new ValidationError(newPath, eachError.getErrorMessage()));@@ -155,7 +154,6 @@ public abstract class AbstractTableListPropertyEditContext<T> extends PropertyEdAbstractTableListPropertyEditContext.this.error(errorMessagePrefix + errorMessage);}- @SuppressWarnings("unchecked")@Overridepublic void doValidation() {for (Iterator<String> it = AbstractTableListPropertyEditContext.this.validationErrorMessages.iterator(); it.hasNext();) {@@ -164,7 +162,7 @@ public abstract class AbstractTableListPropertyEditContext<T> extends PropertyEd}if (getBean() instanceof Validatable) {- ((Validatable<T>)getBean()).validate(this);+ ((Validatable)getBean()).validate(this);}}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/BeanEditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/BeanEditContext.javaindex 9922efd6a3..7d84a629fc 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/BeanEditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/BeanEditContext.java@@ -3,17 +3,16 @@ package com.pmease.commons.editable;import java.io.Serializable;@SuppressWarnings("serial")-public abstract class BeanEditContext<T> extends AbstractEditContext<T> {+public abstract class BeanEditContext extends AbstractEditContext {public BeanEditContext(Serializable bean) {super(bean);}- @SuppressWarnings("unchecked")@Overrideprotected void doValidation() {if (getBean() instanceof Validatable) {- ((Validatable<T>)getBean()).validate(this);+ ((Validatable)getBean()).validate(this);}}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/DefaultEditSupportRegistry.java b/commons.editable/src/main/java/com/pmease/commons/editable/DefaultEditSupportRegistry.javaindex 216f781982..f529d7eb94 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/DefaultEditSupportRegistry.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/DefaultEditSupportRegistry.java@@ -9,7 +9,6 @@ import javax.inject.Singleton;import com.pmease.commons.util.GeneralException;@Singleton-@SuppressWarnings("rawtypes")public class DefaultEditSupportRegistry implements EditSupportRegistry {private final Set<EditSupport> editSupports;diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/EditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/EditContext.javaindex 8aa7ab7287..788d6ae091 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/EditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/EditContext.java@@ -4,15 +4,15 @@ import java.io.Serializable;import java.util.List;import java.util.Map;-public interface EditContext<T> extends Serializable {+public interface EditContext extends Serializable {void validate();List<ValidationError> getValidationErrors(boolean recursive);- Map<Serializable, EditContext<T>> getChildContexts();+ Map<Serializable, EditContext> getChildContexts();- EditContext<T> getChildContext(Serializable propertyName);+ EditContext getChildContext(Serializable propertyName);boolean hasError(Serializable propertyName, boolean recursive);@@ -20,8 +20,8 @@ public interface EditContext<T> extends Serializable {void error(String errorMessage);- void renderForEdit(T renderContext);+ Object renderForEdit(Object renderParam);- void renderForView(T renderContext);+ Object renderForView(Object renderParam);}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/EditSupport.java b/commons.editable/src/main/java/com/pmease/commons/editable/EditSupport.javaindex b05ff6a939..40dcd2c7bf 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/EditSupport.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/EditSupport.java@@ -5,10 +5,10 @@ import java.io.Serializable;import com.pmease.commons.loader.ExtensionPoint;@ExtensionPoint-public interface EditSupport<T> {+public interface EditSupport {- BeanEditContext<T> getBeanEditContext(Serializable bean);+ BeanEditContext getBeanEditContext(Serializable bean);- PropertyEditContext<T> getPropertyEditContext(Serializable bean, String propertyName);+ PropertyEditContext getPropertyEditContext(Serializable bean, String propertyName);}diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/EditSupportRegistry.java b/commons.editable/src/main/java/com/pmease/commons/editable/EditSupportRegistry.javaindex 5ff175dc12..5081189ffe 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/EditSupportRegistry.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/EditSupportRegistry.java@@ -5,7 +5,6 @@ import java.io.Serializable;import com.google.inject.ImplementedBy;@ImplementedBy(DefaultEditSupportRegistry.class)-@SuppressWarnings("rawtypes")public interface EditSupportRegistry {BeanEditContext getBeanEditContext(Serializable bean);diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/EditableUtils.java b/commons.editable/src/main/java/com/pmease/commons/editable/EditableUtils.javaindex 852a5303e8..c5afd80605 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/EditableUtils.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/EditableUtils.java@@ -110,7 +110,6 @@ public class EditableUtils {return null;}- @SuppressWarnings({ "rawtypes", "unchecked" })public static void validate(Serializable bean) {EditContext context = AppLoader.getInstance(EditSupportRegistry.class).getBeanEditContext(bean);context.validate();diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/PropertyEditContext.java b/commons.editable/src/main/java/com/pmease/commons/editable/PropertyEditContext.javaindex e3ee6a8eb1..882c314ed4 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/PropertyEditContext.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/PropertyEditContext.java@@ -16,7 +16,7 @@ import com.pmease.commons.util.ExceptionUtils;import com.pmease.commons.util.ReflectionUtils;@SuppressWarnings("serial")-public abstract class PropertyEditContext<T> extends AbstractEditContext<T> {+public abstract class PropertyEditContext extends AbstractEditContext {private final String propertyName;diff --git a/commons.editable/src/main/java/com/pmease/commons/editable/Validatable.java b/commons.editable/src/main/java/com/pmease/commons/editable/Validatable.javaindex a5ed4f9f36..a0ce9fc2b2 100644--- a/commons.editable/src/main/java/com/pmease/commons/editable/Validatable.java+++ b/commons.editable/src/main/java/com/pmease/commons/editable/Validatable.java@@ -1,7 +1,7 @@package com.pmease.commons.editable;-public interface Validatable<T> {+public interface Validatable {- void validate(EditContext<T> editContext);+ void validate(EditContext editContext);}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/WicketModule.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/WicketModule.javaindex b6aceef8f3..bcfe5e9997 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/WicketModule.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/WicketModule.java@@ -6,7 +6,7 @@ import org.apache.wicket.protocol.http.WicketServlet;import com.pmease.commons.editable.EditSupport;import com.pmease.commons.jetty.ServletContextConfigurator;import com.pmease.commons.loader.AbstractPluginModule;-import com.pmease.commons.wicket.editable.RenderContext;+import com.pmease.commons.wicket.editable.EditHelper;public class WicketModule extends AbstractPluginModule {@@ -19,7 +19,7 @@ public class WicketModule extends AbstractPluginModule {contribute(ServletContextConfigurator.class, WicketServletContextConfigurator.class);- contributeFromPackage(EditSupport.class, RenderContext.class);+ contributeFromPackage(EditSupport.class, EditHelper.class);}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.css b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.cssindex def217a853..ac18ce1c28 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.css+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/common.css@@ -110,4 +110,20 @@ table td, table th {.required {color: #B94A48;-}\ No newline at end of file+}++.left-spacing {+ margin-left: 10px;+}+.right-spacing {+ margin-right: 10px;+}+.top-spacing {+ margin-top: 10px;+}+.bottom-spacing {+ margin-bottom: 10px;+}+.spacing {+ margin: 10px;+}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/EditHelper.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/EditHelper.javaindex cf216d7f48..ca3814ffd5 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/EditHelper.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/EditHelper.java@@ -2,20 +2,28 @@ package com.pmease.commons.wicket.editable;import java.io.Serializable;+import org.apache.wicket.Component;+import com.pmease.commons.editable.EditContext;import com.pmease.commons.editable.EditSupportRegistry;import com.pmease.commons.loader.AppLoader;public class EditHelper {- @SuppressWarnings("unchecked")- public static EditContext<RenderContext> getContext(Serializable bean) {+ public static EditContext getContext(Serializable bean) {return AppLoader.getInstance(EditSupportRegistry.class).getBeanEditContext(bean);}- @SuppressWarnings("unchecked")- public static EditContext<RenderContext> getContext(Serializable bean, String propertyName) {+ public static EditContext getContext(Serializable bean, String propertyName) {return AppLoader.getInstance(EditSupportRegistry.class).getPropertyEditContext(bean, propertyName);}+ public static Component renderForEdit(EditContext editContext, String componentId) {+ return (Component) editContext.renderForEdit(componentId);+ }++ public static Component renderForView(EditContext editContext, String componentId) {+ return (Component) editContext.renderForView(componentId);+ }+}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/RenderContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/RenderContext.javadeleted file mode 100644index 009605b1b4..0000000000--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/RenderContext.java+++ /dev/null@@ -1,24 +0,0 @@-package com.pmease.commons.wicket.editable;--import org.apache.wicket.MarkupContainer;--public class RenderContext {-- private final MarkupContainer container;-- private final String componentId;-- public RenderContext(MarkupContainer container, String componentId) {- this.container = container;- this.componentId = componentId;- }-- public MarkupContainer getContainer() {- return container;- }-- public String getComponentId() {- return componentId;- }--}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/BooleanEditSupport.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/BooleanEditSupport.javaindex 9cf9b0d3dc..51d03e7ea3 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/BooleanEditSupport.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/BooleanEditSupport.java@@ -7,17 +7,16 @@ import com.pmease.commons.editable.BeanEditContext;import com.pmease.commons.editable.EditSupport;import com.pmease.commons.editable.PropertyEditContext;import com.pmease.commons.util.BeanUtils;-import com.pmease.commons.wicket.editable.RenderContext;-public class BooleanEditSupport implements EditSupport<RenderContext> {+public class BooleanEditSupport implements EditSupport {@Override- public BeanEditContext<RenderContext> getBeanEditContext(Serializable bean) {+ public BeanEditContext getBeanEditContext(Serializable bean) {return null;}@Override- public PropertyEditContext<RenderContext> getPropertyEditContext(Serializable bean, String propertyName) {+ public PropertyEditContext getPropertyEditContext(Serializable bean, String propertyName) {Method propertyGetter = BeanUtils.getGetter(bean.getClass(), propertyName);Class<?> propertyClass = propertyGetter.getReturnType();if (propertyClass == boolean.class) {diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/BooleanPropertyEditContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/BooleanPropertyEditContext.javaindex fc04e7cddb..c9ed45951d 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/BooleanPropertyEditContext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/BooleanPropertyEditContext.java@@ -3,6 +3,7 @@ package com.pmease.commons.wicket.editable.bool;import java.io.Serializable;import java.util.Map;+import org.apache.wicket.Component;import org.apache.wicket.markup.ComponentTag;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.CheckBox;@@ -10,18 +11,17 @@ import org.apache.wicket.model.IModel;import com.pmease.commons.editable.EditContext;import com.pmease.commons.editable.PropertyEditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class BooleanPropertyEditContext extends PropertyEditContext<RenderContext> {+public class BooleanPropertyEditContext extends PropertyEditContext {public BooleanPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);}@Override- public void renderForEdit(RenderContext renderContext) {- renderContext.getContainer().add(new CheckBox(renderContext.getComponentId(), new IModel<Boolean>() {+ public Component renderForEdit(Object renderParam) {+ return new CheckBox((String)renderParam, new IModel<Boolean>() {@Overridepublic void detach() {@@ -46,16 +46,16 @@ public class BooleanPropertyEditContext extends PropertyEditContext<RenderContexsuper.onComponentTag(tag);}- });+ };}@Override- public void renderForView(RenderContext renderContext) {- renderContext.getContainer().add(new Label(renderContext.getComponentId(), getPropertyValue().toString()));+ public Component renderForView(Object renderParam) {+ return new Label((String) renderParam, getPropertyValue().toString());}@Override- public Map<Serializable, EditContext<RenderContext>> getChildContexts() {+ public Map<Serializable, EditContext> getChildContexts() {return null;}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/NullableBooleanPropertyEditContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/NullableBooleanPropertyEditContext.javaindex 96bfa9bfe4..d1e1f3ac55 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/NullableBooleanPropertyEditContext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/bool/NullableBooleanPropertyEditContext.java@@ -11,19 +11,17 @@ import org.apache.wicket.model.IModel;import com.pmease.commons.editable.EditContext;import com.pmease.commons.editable.PropertyEditContext;import com.pmease.commons.util.EasyList;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class NullableBooleanPropertyEditContext extends PropertyEditContext<RenderContext> {+public class NullableBooleanPropertyEditContext extends PropertyEditContext {public NullableBooleanPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);}@Override- public void renderForEdit(RenderContext renderContext) {-- DropDownChoice<String> dropDownChoice = new DropDownChoice<String>(renderContext.getComponentId(), new IModel<String>() {+ public Object renderForEdit(Object renderParam) {+ DropDownChoice<String> dropDownChoice = new DropDownChoice<String>((String) renderParam, new IModel<String>() {public void detach() {}@@ -62,24 +60,24 @@ public class NullableBooleanPropertyEditContext extends PropertyEditContext<RenddropDownChoice.setNullValid(true);- renderContext.getContainer().add(dropDownChoice);+ return dropDownChoice;}@Override- public void renderForView(RenderContext renderContext) {+ public Object renderForView(Object renderParam) {Boolean propertyValue = (Boolean) getPropertyValue();if (propertyValue != null) {if (propertyValue)- renderContext.getContainer().add(new Label(renderContext.getComponentId(), "yes"));+ return new Label((String) renderParam, "yes");else- renderContext.getContainer().add(new Label(renderContext.getComponentId(), "no"));+ return new Label((String) renderParam, "no");} else {- renderContext.getContainer().add(new Label(renderContext.getComponentId()));+ return new Label((String) renderParam, "<i>Not Defined</i>").setEscapeModelStrings(false);}}@Override- public Map<Serializable, EditContext<RenderContext>> getChildContexts() {+ public Map<Serializable, EditContext> getChildContexts() {return null;}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/editable.css b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/editable.cssindex 0b208ecde1..1b97a622de 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/editable.css+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/editable.css@@ -12,6 +12,11 @@ table.reflection>tbody>tr>td.name {font-weight: bold;background: #EDEDED;text-align: right;+ white-space: nowrap;+ width: 20%;+}+table.reflection td.value {+ font-size: 13px;}table.reflection td input.enable, table.reflection td select.type {margin-bottom: 8px;@@ -26,3 +31,15 @@ table.list.editor input, table.list.editor select {td.no-elements {font-style: italic;}++table.polymorphic {+ width: 100%;+}+table.reflection table.reflection {+ margin-bottom: 10px;+}+table.reflection input[type="text"], table.reflection select {+ width: 100%;+ height: 32px;+ font-size: 13px;+}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/ListEditSupport.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/ListEditSupport.javaindex c1dbca2cd8..d7a7302a48 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/ListEditSupport.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/ListEditSupport.java@@ -5,21 +5,19 @@ import java.io.Serializable;import com.pmease.commons.editable.AbstractListEditSupport;import com.pmease.commons.editable.AbstractPolymorphicListPropertyEditContext;import com.pmease.commons.editable.AbstractTableListPropertyEditContext;-import com.pmease.commons.wicket.editable.RenderContext;import com.pmease.commons.wicket.editable.list.polymorphic.PolymorphicListPropertyEditConext;import com.pmease.commons.wicket.editable.list.table.TableListPropertyEditContext;-public class ListEditSupport extends AbstractListEditSupport<RenderContext> {+public class ListEditSupport extends AbstractListEditSupport {@Override- protected AbstractPolymorphicListPropertyEditContext<RenderContext> newPolymorphicListEditContext(+ protected AbstractPolymorphicListPropertyEditContext newPolymorphicListEditContext(Serializable bean, String propertyName) {return new PolymorphicListPropertyEditConext(bean, propertyName);}@Override- protected AbstractTableListPropertyEditContext<RenderContext> newTableListEditContext(- Serializable bean, String propertyName) {+ protected AbstractTableListPropertyEditContext newTableListEditContext(Serializable bean, String propertyName) {return new TableListPropertyEditContext(bean, propertyName);}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditConext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditConext.javaindex c0693add38..e48a25e847 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditConext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditConext.java@@ -2,26 +2,29 @@ package com.pmease.commons.wicket.editable.list.polymorphic;import java.io.Serializable;+import org.apache.wicket.markup.html.basic.Label;+import com.pmease.commons.editable.AbstractPolymorphicListPropertyEditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class PolymorphicListPropertyEditConext extends AbstractPolymorphicListPropertyEditContext<RenderContext> {+public class PolymorphicListPropertyEditConext extends AbstractPolymorphicListPropertyEditContext {public PolymorphicListPropertyEditConext(Serializable bean, String propertyName) {super(bean, propertyName);}@Override- public void renderForEdit(RenderContext renderContext) {- // TODO Auto-generated method stub-+ public Object renderForEdit(Object renderParam) {+ return new PolymorphicListPropertyEditor((String) renderParam, this);}@Override- public void renderForView(RenderContext renderContext) {- // TODO Auto-generated method stub-+ public Object renderForView(Object renderParam) {+ if (getElementContexts() != null) {+ return new PolymorphicListPropertyViewer((String) renderParam, this);+ } else {+ return new Label((String) renderParam, "<i>Not Defined</i>").setEscapeModelStrings(false);+ }}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditor.html b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditor.htmlnew file mode 100644index 0000000000..ad41a247eb--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditor.html@@ -0,0 +1,39 @@+<wicket:panel>+ <wicket:enclosure child:id="enable">+ <input wicket:id="enable" type="checkbox" class="enable"></input>+ </wicket:enclosure>+ <table wicket:id="valueEditor" class="polymorphic editor">+ <tbody>+ <tr wicket:id="elements">+ <td>+ <div class="clearfix">+ <div class="pull-left right-spacing">+ <select wicket:id="elementTypeSelector" class="type form-control"></select>+ </div>+ <div class="pull-left">+ <a wicket:id="deleteElement" class="btn btn-danger btn-sm">Delete</a>+ </div>+ </div>+ <div wicket:id="elementEditor"></div>+ <wicket:enclosure child="elementValidationErrors">+ <ul class="help-block">+ <li wicket:id="elementValidationErrors">+ <span wicket:id="elementValidationError"></span>+ </li>+ </ul>+ </wicket:enclosure>+ </td>+ </tr>+ <wicket:enclosure>+ <tr>+ <td wicket:id="noElements" class="no-elements">No Elements Defined</td>+ </tr>+ </wicket:enclosure>+ </tbody>+ <tfoot>+ <tr>+ <td wicket:id="addElement"><a wicket:id="addElement" class="btn btn-primary btn-sm">Add New</a></td>+ </tr>+ </tfoot>+ </table>+</wicket:panel>\ No newline at end of filediff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditor.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditor.javanew file mode 100644index 0000000000..2d1ca3f9e6--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyEditor.java@@ -0,0 +1,220 @@+package com.pmease.commons.wicket.editable.list.polymorphic;++import java.io.Serializable;+import java.util.ArrayList;+import java.util.List;++import org.apache.wicket.AttributeModifier;+import org.apache.wicket.Component;+import org.apache.wicket.ajax.AjaxRequestTarget;+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;+import org.apache.wicket.ajax.markup.html.form.AjaxButton;+import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.markup.html.form.CheckBox;+import org.apache.wicket.markup.html.form.DropDownChoice;+import org.apache.wicket.markup.html.form.Form;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.ListView;+import org.apache.wicket.markup.html.panel.Panel;+import org.apache.wicket.model.IModel;++import com.pmease.commons.editable.BeanEditContext;+import com.pmease.commons.editable.EditableUtils;+import com.pmease.commons.editable.ValidationError;+import com.pmease.commons.wicket.WicketUtils;++@SuppressWarnings("serial")+public class PolymorphicListPropertyEditor extends Panel {++ private static final String ELEMENT_EDITOR_ID = "elementEditor";++ private final PolymorphicListPropertyEditConext editContext;++ public PolymorphicListPropertyEditor(String id, PolymorphicListPropertyEditConext editContext) {+ super(id);+ this.editContext = editContext;+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ if (editContext.isPropertyRequired()) {+ add(new WebMarkupContainer("enable").setVisible(false));+ if (editContext.getPropertyValue() == null) {+ editContext.setPropertyValue(editContext.instantiate(editContext.getPropertyGetter().getReturnType()));+ }+ } else {+ add(new CheckBox("enable", new IModel<Boolean>() {++ @Override+ public void detach() {++ }++ @Override+ public Boolean getObject() {+ return editContext.getPropertyValue() != null;+ }++ @Override+ public void setObject(Boolean object) {+ if (object) {+ editContext.setPropertyValue(editContext.instantiate(ArrayList.class));+ } else {+ editContext.setPropertyValue(null);+ }+ }++ }).add(new AjaxFormComponentUpdatingBehavior("onclick"){++ @Override+ protected void onUpdate(AjaxRequestTarget target) {+ Component editor = newPropertyValueEditor();+ replace(editor);+ target.add(editor);+ }++ }));++ }++ add(newPropertyValueEditor());+ }++ private Component newPropertyValueEditor() {+ final WebMarkupContainer table = new WebMarkupContainer("valueEditor") {++ @Override+ protected void onConfigure() {+ super.onConfigure();+ setVisible(editContext.getElementContexts() != null);+ }++ };++ table.setOutputMarkupId(true);+ table.setOutputMarkupPlaceholderTag(true);++ table.add(new ListView<BeanEditContext>("elements", editContext.getElementContexts()) {++ @Override+ protected void populateItem(final ListItem<BeanEditContext> item) {+ List<String> implementationNames = new ArrayList<String>();+ for (Class<?> each: editContext.getImplementations())+ implementationNames.add(EditableUtils.getName(each));++ item.add(new DropDownChoice<String>("elementTypeSelector", new IModel<String>() {++ @Override+ public void detach() {+ }++ @Override+ public String getObject() {+ return EditableUtils.getName(item.getModelObject().getBean().getClass());+ }++ @Override+ public void setObject(String object) {+ for (Class<?> each: editContext.getImplementations()) {+ if (EditableUtils.getName(each).equals(object)) {+ Serializable newElementValue = editContext.instantiate(each);+ editContext.removeElement(item.getIndex());+ editContext.addElement(item.getIndex(), newElementValue);+ item.setModelObject(editContext.getElementContexts().get(item.getIndex()));+ return;+ }+ }++ throw new IllegalStateException("Unable to find implementation with name: " + object);+ }++ }, implementationNames).setNullValid(false).add(new AjaxFormComponentUpdatingBehavior("onclick"){++ @Override+ protected void onUpdate(AjaxRequestTarget target) {+ Component elementEditor = newElementEditor(item.getModelObject());+ item.replace(elementEditor);+ target.add(elementEditor);+ }++ }));++ item.add(new AjaxButton("deleteElement") {++ @Override+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {+ super.onSubmit(target, form);++ WicketUtils.updateFormModels(form);+ editContext.removeElement(item.getIndex());+ target.add(table);+ }++ }.setDefaultFormProcessing(false));++ if (!item.getModelObject().getValidationErrors(false).isEmpty())+ item.add(AttributeModifier.append("class", "has-error"));++ item.add(new ListView<ValidationError>("elementValidationErrors", item.getModelObject().getValidationErrors(false)) {++ @Override+ protected void populateItem(ListItem<ValidationError> item) {+ ValidationError error = item.getModelObject();+ item.add(new Label("propertyValidationError", error.toString()));+ }++ @Override+ protected void onConfigure() {+ super.onConfigure();++ setVisible(!item.getModelObject().getValidationErrors(false).isEmpty());+ }++ });++ item.add(newElementEditor(item.getModelObject()));+ }++ });++ table.add(new WebMarkupContainer("noElements") {++ @Override+ protected void onConfigure() {+ super.onConfigure();+ setVisible(editContext.getElementContexts().isEmpty());+ }++ });++ WebMarkupContainer newRow = new WebMarkupContainer("addElement");+ newRow.add(new AjaxButton("addElement") {++ @Override+ public void onSubmit(AjaxRequestTarget target, Form<?> form) {+ super.onSubmit(target, form);++ WicketUtils.updateFormModels(form);+ editContext.addElement(editContext.getElementContexts().size(),+ editContext.instantiate(editContext.getImplementations().get(0)));+ target.add(table);+ }++ }.setDefaultFormProcessing(false));++ table.add(newRow);++ return table;+ }++ private Component newElementEditor(BeanEditContext elementContext) {+ Component elementEditor = (Component)elementContext.renderForEdit(ELEMENT_EDITOR_ID);+ elementEditor.setOutputMarkupId(true);+ elementEditor.setOutputMarkupPlaceholderTag(true);+ return elementEditor;+ }++}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyViewer.html b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyViewer.htmlnew file mode 100644index 0000000000..e0c7bb317e--- /dev/null+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyViewer.html@@ -0,0 +1,14 @@+<wicket:panel>+ <table class="polymorphic viewer">+ <tbody>+ <tr wicket:id="elements">+ <td>+ <div wicket:id="element"></div>+ </td>+ </tr>+ <tr wicket:id="noElements">+ <td class="no-elements">No Elements Defined</td>+ </tr>+ </tbody>+ </table>+</wicket:panel>\ No newline at end of filediff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyViewer.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyViewer.javaindex bc9e12a634..a589fdba53 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyViewer.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/polymorphic/PolymorphicListPropertyViewer.java@@ -1,14 +1,44 @@package com.pmease.commons.wicket.editable.list.polymorphic;+import org.apache.wicket.Component;+import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.ListView;import org.apache.wicket.markup.html.panel.Panel;-import com.pmease.commons.wicket.editable.list.table.TableListPropertyEditContext;+import com.pmease.commons.editable.BeanEditContext;@SuppressWarnings("serial")public class PolymorphicListPropertyViewer extends Panel {- public PolymorphicListPropertyViewer(String id, TableListPropertyEditContext editContext) {+ private final PolymorphicListPropertyEditConext editContext;++ public PolymorphicListPropertyViewer(String id, PolymorphicListPropertyEditConext editContext) {super(id);+ this.editContext = editContext;+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ add(new ListView<BeanEditContext>("elements", editContext.getElementContexts()) {++ @Override+ protected void populateItem(ListItem<BeanEditContext> item) {+ item.add((Component)item.getModelObject().renderForView("element"));+ }++ });+ add(new WebMarkupContainer("noElements") {++ @Override+ protected void onConfigure() {+ super.onConfigure();+ setVisible(editContext.getElementContexts().isEmpty());+ }++ });}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyEditContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyEditContext.javaindex 76bb6c36b7..90464053e5 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyEditContext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyEditContext.java@@ -2,24 +2,29 @@ package com.pmease.commons.wicket.editable.list.table;import java.io.Serializable;+import org.apache.wicket.markup.html.basic.Label;+import com.pmease.commons.editable.AbstractTableListPropertyEditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class TableListPropertyEditContext extends AbstractTableListPropertyEditContext<RenderContext> {+public class TableListPropertyEditContext extends AbstractTableListPropertyEditContext {public TableListPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);}@Override- public void renderForEdit(RenderContext renderContext) {- renderContext.getContainer().add(new TableListPropertyEditor(renderContext.getComponentId(), this));+ public Object renderForEdit(Object renderParam) {+ return new TableListPropertyEditor((String) renderParam, this);}@Override- public void renderForView(RenderContext renderContext) {- renderContext.getContainer().add(new TableListPropertyViewer(renderContext.getComponentId(), this));+ public Object renderForView(Object renderParam) {+ if (getElementContexts() != null) {+ return new TableListPropertyViewer((String) renderParam, this);+ } else {+ return new Label((String) renderParam, "<i>Not Defined</i>").setEscapeModelStrings(false);+ }}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyEditor.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyEditor.javaindex 9a30d91b81..3842e5137c 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyEditor.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyEditor.java@@ -23,7 +23,6 @@ import com.pmease.commons.editable.EditableUtils;import com.pmease.commons.editable.PropertyEditContext;import com.pmease.commons.editable.ValidationError;import com.pmease.commons.wicket.WicketUtils;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")public class TableListPropertyEditor extends Panel {@@ -111,16 +110,16 @@ public class TableListPropertyEditor extends Panel {}});- table.add(new ListView<List<PropertyEditContext<RenderContext>>>("elements", editContext.getElementContexts()) {+ table.add(new ListView<List<PropertyEditContext>>("elements", editContext.getElementContexts()) {@Override- protected void populateItem(final ListItem<List<PropertyEditContext<RenderContext>>> rowItem) {- rowItem.add(new ListView<PropertyEditContext<RenderContext>>("elementProperties", rowItem.getModelObject()) {+ protected void populateItem(final ListItem<List<PropertyEditContext>> rowItem) {+ rowItem.add(new ListView<PropertyEditContext>("elementProperties", rowItem.getModelObject()) {@Override- protected void populateItem(ListItem<PropertyEditContext<RenderContext>> columnItem) {- final PropertyEditContext<RenderContext> elementPropertyContext = columnItem.getModelObject();- elementPropertyContext.renderForEdit(new RenderContext(columnItem, "elementPropertyEditor"));+ protected void populateItem(ListItem<PropertyEditContext> columnItem) {+ final PropertyEditContext elementPropertyContext = columnItem.getModelObject();+ columnItem.add((Component)elementPropertyContext.renderForEdit("elementPropertyEditor"));columnItem.add(new ListView<ValidationError>("propertyValidationErrors", elementPropertyContext.getValidationErrors(false)) {diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyViewer.html b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyViewer.htmlindex cf7f5a2a12..dd18d0ae8a 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyViewer.html+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyViewer.html@@ -1,5 +1,5 @@<wicket:panel>- <table wicket:id="table" class="list viewer table table-condensed">+ <table class="list viewer table table-condensed"><thead><th wicket:id="headers"><span wicket:id="header"></span>diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyViewer.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyViewer.javaindex 0f25ec1e5d..1b25888222 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyViewer.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/table/TableListPropertyViewer.java@@ -4,6 +4,7 @@ import java.lang.reflect.Method;import java.util.List;import org.apache.wicket.AttributeModifier;+import org.apache.wicket.Component;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.list.ListItem;@@ -14,7 +15,6 @@ import org.apache.wicket.model.LoadableDetachableModel;import com.pmease.commons.editable.EditContext;import com.pmease.commons.editable.EditableUtils;import com.pmease.commons.editable.PropertyEditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")public class TableListPropertyViewer extends Panel {@@ -30,16 +30,7 @@ public class TableListPropertyViewer extends Panel {protected void onInitialize() {super.onInitialize();- WebMarkupContainer table = new WebMarkupContainer("table") {-- @Override- protected void onConfigure() {- super.onConfigure();- setVisible(editContext.getElementContexts() != null);- }-- };- table.add(new ListView<Method>("headers", new LoadableDetachableModel<List<Method>>() {+ add(new ListView<Method>("headers", new LoadableDetachableModel<List<Method>>() {@Overrideprotected List<Method> load() {@@ -54,16 +45,16 @@ public class TableListPropertyViewer extends Panel {}});- table.add(new ListView<List<PropertyEditContext<RenderContext>>>("rows", editContext.getElementContexts()) {+ add(new ListView<List<PropertyEditContext>>("rows", editContext.getElementContexts()) {@Override- protected void populateItem(ListItem<List<PropertyEditContext<RenderContext>>> rowItem) {- rowItem.add(new ListView<PropertyEditContext<RenderContext>>("columns", rowItem.getModelObject()) {+ protected void populateItem(ListItem<List<PropertyEditContext>> rowItem) {+ rowItem.add(new ListView<PropertyEditContext>("columns", rowItem.getModelObject()) {@Override- protected void populateItem(ListItem<PropertyEditContext<RenderContext>> columnItem) {- EditContext<RenderContext> elementPropertyContext = columnItem.getModelObject();- elementPropertyContext.renderForView(new RenderContext(columnItem, "cell"));+ protected void populateItem(ListItem<PropertyEditContext> columnItem) {+ EditContext elementPropertyContext = columnItem.getModelObject();+ columnItem.add((Component)elementPropertyContext.renderForView("cell"));}});@@ -80,9 +71,7 @@ public class TableListPropertyViewer extends Panel {};noElements.add(AttributeModifier.append("colspan", editContext.getElementPropertyGetters().size()));- table.add(noElements);-- add(table);+ add(noElements);}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/nuemric/NumericEditSupport.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/nuemric/NumericEditSupport.javaindex 48de825d4f..779df3fa4a 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/nuemric/NumericEditSupport.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/nuemric/NumericEditSupport.java@@ -7,17 +7,16 @@ import com.pmease.commons.editable.BeanEditContext;import com.pmease.commons.editable.EditSupport;import com.pmease.commons.editable.PropertyEditContext;import com.pmease.commons.util.BeanUtils;-import com.pmease.commons.wicket.editable.RenderContext;-public class NumericEditSupport implements EditSupport<RenderContext> {+public class NumericEditSupport implements EditSupport {@Override- public BeanEditContext<RenderContext> getBeanEditContext(Serializable bean) {+ public BeanEditContext getBeanEditContext(Serializable bean) {return null;}@Override- public PropertyEditContext<RenderContext> getPropertyEditContext(Serializable bean, String propertyName) {+ public PropertyEditContext getPropertyEditContext(Serializable bean, String propertyName) {Method propertyGetter = BeanUtils.getGetter(bean.getClass(), propertyName);Class<?> propertyClass = propertyGetter.getReturnType();if (propertyClass == int.class || propertyClass == long.classdiff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/nuemric/NumericPropertyEditContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/nuemric/NumericPropertyEditContext.javaindex b82d3cfec2..eba54e07c2 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/nuemric/NumericPropertyEditContext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/nuemric/NumericPropertyEditContext.java@@ -9,10 +9,9 @@ import org.apache.wicket.model.Model;import com.pmease.commons.editable.EditContext;import com.pmease.commons.editable.PropertyEditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class NumericPropertyEditContext extends PropertyEditContext<RenderContext> {+public class NumericPropertyEditContext extends PropertyEditContext {private final IModel<String> inputModel;@@ -30,17 +29,17 @@ public class NumericPropertyEditContext extends PropertyEditContext<RenderContex}@Override- public void renderForEdit(RenderContext renderContext) {- renderContext.getContainer().add(new NumericPropertyEditor(renderContext.getComponentId(), this));+ public Object renderForEdit(Object renderParam) {+ return new NumericPropertyEditor((String) renderParam, this);}@Override- public void renderForView(RenderContext renderContext) {+ public Object renderForView(Object renderParam) {Object propertyValue = getPropertyValue();if (propertyValue != null)- renderContext.getContainer().add(new Label(renderContext.getComponentId(), propertyValue.toString()));+ return new Label((String) renderParam, propertyValue.toString());else- renderContext.getContainer().add(new Label(renderContext.getComponentId()));+ return new Label((String) renderParam, "<i>Not Defined</i>").setEscapeModelStrings(false);}@Override@@ -64,7 +63,7 @@ public class NumericPropertyEditContext extends PropertyEditContext<RenderContex}@Override- public Map<Serializable, EditContext<RenderContext>> getChildContexts() {+ public Map<Serializable, EditContext> getChildContexts() {return null;}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicEditSuport.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicEditSuport.javaindex 76e0aae0c5..40e9ce0b7e 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicEditSuport.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicEditSuport.java@@ -4,12 +4,11 @@ import java.io.Serializable;import com.pmease.commons.editable.AbstractPolymorphicEditSupport;import com.pmease.commons.editable.AbstractPolymorphicPropertyEditContext;-import com.pmease.commons.wicket.editable.RenderContext;-public class PolymorphicEditSuport extends AbstractPolymorphicEditSupport<RenderContext> {+public class PolymorphicEditSuport extends AbstractPolymorphicEditSupport {@Override- protected AbstractPolymorphicPropertyEditContext<RenderContext> newPolymorphicPropertyEditContext(+ protected AbstractPolymorphicPropertyEditContext newPolymorphicPropertyEditContext(Serializable bean, String propertyName) {return new PolymorphicPropertyEditContext(bean, propertyName);}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicPropertyEditContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicPropertyEditContext.javaindex 83e01ef531..8b88614e28 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicPropertyEditContext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicPropertyEditContext.java@@ -2,31 +2,31 @@ package com.pmease.commons.wicket.editable.polymorphic;import java.io.Serializable;-import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.basic.Label;import com.pmease.commons.editable.AbstractPolymorphicPropertyEditContext;import com.pmease.commons.editable.EditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class PolymorphicPropertyEditContext extends AbstractPolymorphicPropertyEditContext<RenderContext> {+public class PolymorphicPropertyEditContext extends AbstractPolymorphicPropertyEditContext {public PolymorphicPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);}@Override- public void renderForEdit(RenderContext renderContext) {- renderContext.getContainer().add(new PolymorphicPropertyEditor(renderContext.getComponentId(), this));+ public Object renderForEdit(Object renderParam) {+ return new PolymorphicPropertyEditor((String) renderParam, this);}@Override- public void renderForView(RenderContext renderContext) {- EditContext<RenderContext> valueContext = getValueContext();+ public Object renderForView(Object renderParam) {+ EditContext valueContext = getValueContext();+if (valueContext != null)- valueContext.renderForView(renderContext);+ return valueContext.renderForView(renderParam);else- renderContext.getContainer().add(new WebMarkupContainer(renderContext.getComponentId()));+ return new Label((String) renderParam, "<i>Not Defined</i>").setEscapeModelStrings(false);}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicPropertyEditor.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicPropertyEditor.javaindex e333a1d345..46334dfbab 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicPropertyEditor.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/polymorphic/PolymorphicPropertyEditor.java@@ -14,7 +14,6 @@ import org.apache.wicket.model.IModel;import com.pmease.commons.editable.EditContext;import com.pmease.commons.editable.EditableUtils;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")public class PolymorphicPropertyEditor extends Panel {@@ -71,29 +70,27 @@ public class PolymorphicPropertyEditor extends Panel {@Overrideprotected void onUpdate(AjaxRequestTarget target) {- remove(VALUE_EDITOR_ID);- renderValueEditor();-- Component valueEditor = get(VALUE_EDITOR_ID);+ Component valueEditor = newValueEditor();replace(valueEditor);target.add(valueEditor);}}));- renderValueEditor();+ add(newValueEditor());}- private void renderValueEditor() {- EditContext<RenderContext> valueContext = editContext.getValueContext();+ private Component newValueEditor() {+ EditContext valueContext = editContext.getValueContext();+ Component valueEditor;if (valueContext != null) {- valueContext.renderForEdit(new RenderContext(this, VALUE_EDITOR_ID));+ valueEditor = (Component)valueContext.renderForEdit(VALUE_EDITOR_ID);} else {- add(new WebMarkupContainer(VALUE_EDITOR_ID).setVisible(false));+ valueEditor = new WebMarkupContainer(VALUE_EDITOR_ID).setVisible(false);}- Component valueEditor = get(VALUE_EDITOR_ID);valueEditor.setOutputMarkupId(true);valueEditor.setOutputMarkupPlaceholderTag(true);+ return valueEditor;}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanEditContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanEditContext.javaindex 064517d798..8acebdab09 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanEditContext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanEditContext.java@@ -3,23 +3,22 @@ package com.pmease.commons.wicket.editable.reflection;import java.io.Serializable;import com.pmease.commons.editable.AbstractReflectionBeanEditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class ReflectionBeanEditContext extends AbstractReflectionBeanEditContext<RenderContext> {+public class ReflectionBeanEditContext extends AbstractReflectionBeanEditContext {public ReflectionBeanEditContext(Serializable bean) {super(bean);}@Override- public void renderForEdit(RenderContext renderContext) {- renderContext.getContainer().add(new ReflectionBeanEditor(renderContext.getComponentId(), this));+ public Object renderForEdit(Object renderParam) {+ return new ReflectionBeanEditor((String) renderParam, this);}@Override- public void renderForView(RenderContext renderContext) {- renderContext.getContainer().add(new ReflectionBeanViewer(renderContext.getComponentId(), this));+ public Object renderForView(Object renderParam) {+ return new ReflectionBeanViewer((String) renderParam, this);}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanEditor.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanEditor.javaindex b111147b38..e0a73fbd59 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanEditor.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanEditor.java@@ -3,6 +3,7 @@ package com.pmease.commons.wicket.editable.reflection;import java.util.List;import org.apache.wicket.AttributeModifier;+import org.apache.wicket.Component;import org.apache.wicket.markup.head.IHeaderResponse;import org.apache.wicket.markup.head.JavaScriptHeaderItem;import org.apache.wicket.markup.html.basic.Label;@@ -15,7 +16,6 @@ import com.pmease.commons.editable.EditableUtils;import com.pmease.commons.editable.PropertyEditContext;import com.pmease.commons.editable.ValidationError;import com.pmease.commons.wicket.editable.EditableResourceReference;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")public class ReflectionBeanEditor extends Panel {@@ -56,13 +56,13 @@ public class ReflectionBeanEditor extends Panel {});- add(new ListView<PropertyEditContext<RenderContext>>("properties", editContext.getPropertyContexts()) {+ add(new ListView<PropertyEditContext>("properties", editContext.getPropertyContexts()) {@Override- protected void populateItem(ListItem<PropertyEditContext<RenderContext>> item) {- final PropertyEditContext<RenderContext> propertyContext = item.getModelObject();+ protected void populateItem(ListItem<PropertyEditContext> item) {+ final PropertyEditContext propertyContext = item.getModelObject();item.add(new Label("name", EditableUtils.getName(propertyContext.getPropertyGetter())));- propertyContext.renderForEdit(new RenderContext(item, "value"));+ item.add((Component)propertyContext.renderForEdit("value"));String description = EditableUtils.getDescription(propertyContext.getPropertyGetter());if (description != null)diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanViewer.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanViewer.javaindex 27d63837a1..8055e977fc 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanViewer.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionBeanViewer.java@@ -1,5 +1,6 @@package com.pmease.commons.wicket.editable.reflection;+import org.apache.wicket.Component;import org.apache.wicket.markup.head.IHeaderResponse;import org.apache.wicket.markup.head.JavaScriptHeaderItem;import org.apache.wicket.markup.html.basic.Label;@@ -10,7 +11,6 @@ import org.apache.wicket.markup.html.panel.Panel;import com.pmease.commons.editable.EditableUtils;import com.pmease.commons.editable.PropertyEditContext;import com.pmease.commons.wicket.editable.EditableResourceReference;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")public class ReflectionBeanViewer extends Panel {@@ -27,13 +27,13 @@ public class ReflectionBeanViewer extends Panel {protected void onInitialize() {super.onInitialize();- add(new ListView<PropertyEditContext<RenderContext>>("properties", editContext.getPropertyContexts()) {+ add(new ListView<PropertyEditContext>("properties", editContext.getPropertyContexts()) {@Override- protected void populateItem(ListItem<PropertyEditContext<RenderContext>> item) {+ protected void populateItem(ListItem<PropertyEditContext> item) {item.add(new Label("name", EditableUtils.getName(item.getModelObject().getPropertyGetter())));- item.getModelObject().renderForView(new RenderContext(item, "value"));+ item.add((Component)item.getModelObject().renderForView("value"));}});diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionEditSupport.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionEditSupport.javaindex 6529f6731e..f2b6d4e3a9 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionEditSupport.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionEditSupport.java@@ -3,9 +3,8 @@ package com.pmease.commons.wicket.editable.reflection;import java.io.Serializable;import com.pmease.commons.editable.AbstractReflectionEditSupport;-import com.pmease.commons.wicket.editable.RenderContext;-public class ReflectionEditSupport extends AbstractReflectionEditSupport<RenderContext> {+public class ReflectionEditSupport extends AbstractReflectionEditSupport {@Overrideprotected ReflectionBeanEditContext newReflectionBeanEditContext(Serializable bean) {diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditContext.javaindex e9210df104..08f8bc83e0 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditContext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditContext.java@@ -2,31 +2,30 @@ package com.pmease.commons.wicket.editable.reflection;import java.io.Serializable;-import org.apache.wicket.markup.html.WebMarkupContainer;+import org.apache.wicket.markup.html.basic.Label;import com.pmease.commons.editable.AbstractReflectionPropertyEditContext;import com.pmease.commons.editable.EditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class ReflectionPropertyEditContext extends AbstractReflectionPropertyEditContext<RenderContext> {+public class ReflectionPropertyEditContext extends AbstractReflectionPropertyEditContext {public ReflectionPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);}@Override- public void renderForEdit(RenderContext renderContext) {- renderContext.getContainer().add(new ReflectionPropertyEditor(renderContext.getComponentId(), this));+ public Object renderForEdit(Object renderParam) {+ return new ReflectionPropertyEditor((String) renderParam, this);}@Override- public void renderForView(RenderContext renderContext) {- EditContext<RenderContext> valueContext = getValueContext();+ public Object renderForView(Object renderParam) {+ EditContext valueContext = getValueContext();if (valueContext != null) {- valueContext.renderForView(renderContext);+ return valueContext.renderForView(renderParam);} else {- renderContext.getContainer().add(new WebMarkupContainer(renderContext.getComponentId()));+ return new Label((String) renderParam, "<i>Not Defined</i>").setEscapeModelStrings(false);}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditor.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditor.javaindex 19e9233958..5361e173ba 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditor.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditor.java@@ -9,7 +9,6 @@ import org.apache.wicket.markup.html.panel.Panel;import org.apache.wicket.model.IModel;import com.pmease.commons.editable.EditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")public class ReflectionPropertyEditor extends Panel {@@ -58,28 +57,29 @@ public class ReflectionPropertyEditor extends Panel {@Overrideprotected void onUpdate(AjaxRequestTarget target) {- remove(VALUE_EDITOR_ID);- renderValueEditor();- target.add(get(VALUE_EDITOR_ID));+ Component valueEditor = newValueEditor();+ replace(valueEditor);+ target.add(valueEditor);}}));}- renderValueEditor();+ add(newValueEditor());}- private void renderValueEditor() {- EditContext<RenderContext> valueContext = editContext.getValueContext();+ private Component newValueEditor() {+ EditContext valueContext = editContext.getValueContext();+ Component valueEditor;if (valueContext != null) {- valueContext.renderForEdit(new RenderContext(this, VALUE_EDITOR_ID));+ valueEditor = (Component)valueContext.renderForEdit(VALUE_EDITOR_ID);} else {- add(new WebMarkupContainer(VALUE_EDITOR_ID).setVisible(false));+ valueEditor = new WebMarkupContainer(VALUE_EDITOR_ID).setVisible(false);}- Component valueEditor = get(VALUE_EDITOR_ID);valueEditor.setOutputMarkupId(true);valueEditor.setOutputMarkupPlaceholderTag(true);+ return valueEditor;}}diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/string/StringEditSupport.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/string/StringEditSupport.javaindex ed42b02c56..24237f4c10 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/string/StringEditSupport.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/string/StringEditSupport.java@@ -7,17 +7,16 @@ import com.pmease.commons.editable.BeanEditContext;import com.pmease.commons.editable.EditSupport;import com.pmease.commons.editable.PropertyEditContext;import com.pmease.commons.util.BeanUtils;-import com.pmease.commons.wicket.editable.RenderContext;-public class StringEditSupport implements EditSupport<RenderContext> {+public class StringEditSupport implements EditSupport {@Override- public BeanEditContext<RenderContext> getBeanEditContext(Serializable bean) {+ public BeanEditContext getBeanEditContext(Serializable bean) {return null;}@Override- public PropertyEditContext<RenderContext> getPropertyEditContext(Serializable bean, String propertyName) {+ public PropertyEditContext getPropertyEditContext(Serializable bean, String propertyName) {Method propertyGetter = BeanUtils.getGetter(bean.getClass(), propertyName);if (propertyGetter.getReturnType() == String.class) {return new StringPropertyEditContext(bean, propertyName);diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/string/StringPropertyEditContext.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/string/StringPropertyEditContext.javaindex 059a29e29b..82d9e40510 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/string/StringPropertyEditContext.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/string/StringPropertyEditContext.java@@ -7,27 +7,29 @@ import org.apache.wicket.markup.html.basic.Label;import com.pmease.commons.editable.EditContext;import com.pmease.commons.editable.PropertyEditContext;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")-public class StringPropertyEditContext extends PropertyEditContext<RenderContext> {+public class StringPropertyEditContext extends PropertyEditContext {public StringPropertyEditContext(Serializable bean, String propertyName) {super(bean, propertyName);}@Override- public void renderForEdit(RenderContext renderContext) {- renderContext.getContainer().add(new StringPropertyEditor(renderContext.getComponentId(), this));+ public Object renderForEdit(Object renderParam) {+ return new StringPropertyEditor((String) renderParam, this);}@Override- public void renderForView(RenderContext renderContext) {- renderContext.getContainer().add(new Label(renderContext.getComponentId(), (String) getPropertyValue()));+ public Object renderForView(Object renderParam) {+ if (getPropertyValue() != null)+ return new Label((String) renderParam, (String) getPropertyValue());+ else+ return new Label((String) renderParam, "<i>Not Defined</i>").setEscapeModelStrings(false);}@Override- public Map<Serializable, EditContext<RenderContext>> getChildContexts() {+ public Map<Serializable, EditContext> getChildContexts() {return null;}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/Bean.java b/gitop.web/src/main/java/com/pmease/gitop/web/Bean.javaindex 12eb3d8d0c..f62b9cc3ab 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/Bean.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/Bean.java@@ -13,7 +13,7 @@ import com.pmease.commons.editable.annotation.Editable;@SuppressWarnings("serial")@Editable-public class Bean implements Serializable, Validatable<Void> {+public class Bean implements Serializable, Validatable {private String name;@@ -21,6 +21,8 @@ public class Bean implements Serializable, Validatable<Void> {private List<ChildBean> childs;+ private ChildBean child;+private Integer age;@Editable(description="This is something interesting.")@@ -61,8 +63,17 @@ public class Bean implements Serializable, Validatable<Void> {this.age = age;}+ @Editable+ public ChildBean getChild() {+ return child;+ }++ public void setChild(ChildBean child) {+ this.child = child;+ }+@Override- public void validate(EditContext<Void> editContext) {+ public void validate(EditContext editContext) {editContext.error("tananade");}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/ChildBean.java b/gitop.web/src/main/java/com/pmease/gitop/web/ChildBean.javaindex 6a37825ee2..1ed6de8a3d 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/ChildBean.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/ChildBean.java@@ -10,7 +10,7 @@ import com.pmease.commons.editable.annotation.Editable;@SuppressWarnings("serial")@Editable-public class ChildBean implements Serializable, Validatable<Void> {+public abstract class ChildBean implements Serializable, Validatable {private String childName;private Boolean childMarried;@@ -35,7 +35,7 @@ public class ChildBean implements Serializable, Validatable<Void> {}@Override- public void validate(EditContext<Void> editContext) {+ public void validate(EditContext editContext) {if (!editContext.hasError("childName", true)) {if (childName.startsWith("child") && childMarried) {editContext.error("child can not marry.");diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/HomePage.java b/gitop.web/src/main/java/com/pmease/gitop/web/HomePage.javaindex bad556d521..3d73c3cce4 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/HomePage.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/HomePage.java@@ -2,6 +2,7 @@ package com.pmease.gitop.web;import java.util.ArrayList;+import org.apache.wicket.Component;import org.apache.wicket.feedback.ContainerFeedbackMessageFilter;import org.apache.wicket.markup.head.IHeaderResponse;import org.apache.wicket.markup.head.JavaScriptHeaderItem;@@ -13,7 +14,6 @@ import com.pmease.commons.editable.EditContext;import com.pmease.commons.editable.ValidationError;import com.pmease.commons.wicket.asset.CommonResourceReference;import com.pmease.commons.wicket.editable.EditHelper;-import com.pmease.commons.wicket.editable.RenderContext;@SuppressWarnings("serial")public class HomePage extends WebPage {@@ -22,13 +22,15 @@ public class HomePage extends WebPage {static {bean.setChilds(new ArrayList<ChildBean>());+ bean.getChilds().add(new TimBean());+ bean.getChilds().add(new TinaBean());}@Overrideprotected void onInitialize() {super.onInitialize();- final EditContext<RenderContext> editContext = EditHelper.getContext(bean);+ final EditContext editContext = EditHelper.getContext(bean);Form<?> form = new Form<Void>("form") {@@ -44,7 +46,7 @@ public class HomePage extends WebPage {};add(new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(form)));- editContext.renderForView(new RenderContext(form, "editor"));+ form.add((Component)editContext.renderForView("editor"));add(form);}