@@ -0,0 +1,1252 @@
+package ru.ydn.wicket.wicketorientdb.model;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.List;%0A%0Aimport org.apache.wicket.WicketRuntimeException;%0Aimport org.apache.wicket.model.IModel;%0Aimport org.apache.wicket.model.LoadableDetachableModel;%0A%0Apublic class CollectionAdapterModel%3CT, M extends Collection%3CT%3E%3E extends LoadableDetachableModel%3CList%3CT%3E%3E%0A%7B%0A%09private IModel%3CM%3E model;%0A%09%0A%09public CollectionAdapterModel(IModel%3CM%3E model) %7B%0A%09%09this.model = model;%0A%09%7D%0A%0A%09@Override%0A%09protected List%3CT%3E load() %7B%0A%09%09M ret = model.getObject();%0A%09%09if(ret==null) return null;%0A%09%09else if(ret instanceof List) return (List%3CT%3E)ret;%0A%09%09else return new ArrayList%3CT%3E(ret);%0A%09%7D%0A%09%0A%09@Override%0A%09public void setObject(List%3CT%3E object) %7B%0A%09%09setCollection(object);%0A%09%09super.setObject(object);%0A%09%7D%0A%09%0A%09protected void setCollection(List%3CT%3E object)%0A%09%7B%0A%09%09if(object==null) model.setObject(null);%0A%09%09else %0A%09%09%7B%0A%09%09%09M collection = model.getObject();%0A%09%09%09if(collection!=null)%0A%09%09%09%7B%0A%09%09%09%09collection.clear();%0A%09%09%09%09collection.addAll(object);%0A%09%09%09%7D%0A%09%09%09else%0A%09%09%09%7B%0A%09%09%09%09throw new WicketRuntimeException(%22Creation of collection is not supported. Please override this method of you need support.%22);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09protected void onDetach() %7B%0A%09%09super.onDetach();%0A%09%09model.detach();%0A%09%7D%0A%0A%7D%0A

Add model for transparent transformation of collections to List