X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=wicket%2Fjoe%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fwicket%2Fmodel%2FDetachableEntity.java;fp=wicket%2Fjoe%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fwicket%2Fmodel%2FDetachableEntity.java;h=d94994bb60598973914d16900153fea41fd14dc0;hb=51cc217ee697147805ea23dd777511b82efe94ce;hp=0000000000000000000000000000000000000000;hpb=7cc24116aec0bb2ae0cdec40b31ef745e7a93115;p=utils diff --git a/wicket/joe/src/main/java/org/wamblee/wicket/model/DetachableEntity.java b/wicket/joe/src/main/java/org/wamblee/wicket/model/DetachableEntity.java new file mode 100644 index 00000000..d94994bb --- /dev/null +++ b/wicket/joe/src/main/java/org/wamblee/wicket/model/DetachableEntity.java @@ -0,0 +1,52 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wamblee.wicket.model; + +import org.apache.wicket.model.LoadableDetachableModel; +import org.wamblee.persistence.Detachable; + +/** + * A detachable model that wraps a domain object. + * + */ +public class DetachableEntity extends LoadableDetachableModel { + + private Detachable object; + + /** + * Constructs the model. + * @param aObject Object to construct the model with. + */ + public DetachableEntity(Detachable aObject) { + object = aObject; + } + + @Override + protected void onDetach() { + object.detach(); + } + + @Override + protected T load() { + return object.get(); + } + + @Override + public void setObject(T object) { + throw new UnsupportedOperationException("setObject is not supported on this class"); + } + +}