I don't think one was ever created and it fell off my radar.  If you create
one, can you post yours and post a link to it back on this thread?

Thanks!

--
Jeremy Thomerson
http://www.wickettraining.com



On Wed, Sep 30, 2009 at 4:45 PM, Scott Swank <scott.sw...@gmail.com> wrote:

> I searched the JIRA for IChainingModel and didn't get any hits.  Did
> anyone create a JIRA issue?  Here's an implementation of mine.
>
> public class BaseChainingModel implements IChainingModel {
>        private static final long serialVersionUID = 1L;
>        private Object target;
>
>        public BaseChainingModel(Object modelObject) {
>                if (modelObject == null) {
>                        throw new IllegalArgumentException("Parameter
> modelObject cannot be null");
>                }
>                else {
>                        target = modelObject;
>                }
>        }
>
>        @Override
>        public void detach() {
>                if (target instanceof IDetachable)
>                        ((IDetachable) target).detach();
>        }
>
>        @Override
>        public IModel getChainedModel() {
>                if (target instanceof IModel)
>                        return (IModel) target;
>                else
>                        return null;
>        }
>
>        @Override
>        public void setChainedModel(IModel model) {
>                target = model;
>        }
>
>        @Override
>        public Object getObject() {
>                Object object = target;
>                while (object instanceof IModel) {
>                        Object tmp = ((IModel) object).getObject();
>                        if (tmp == object) {
>                                break; // pathological
>                        }
>                        object = tmp;
>                }
>                return object;
>        }
>
>        @Override
>        public void setObject(Object obj)       {
>                if (target instanceof IModel)
>                        ((IModel) target).setObject(obj);
>                else if (obj == null || obj instanceof Serializable)
>                        target = obj;
>                else
>                        throw new WicketRuntimeException("Model object must
> be Serializable");
>        }
>
> }
>
> Scott
>
>
> On Wed, Apr 8, 2009 at 2:53 PM, Jeremy Thomerson
> <jer...@wickettraining.com> wrote:
> > I think that's a good idea - I have done a similar thing in my own
> > projects.  Please open a JIRA so this idea doesn't get lost, but this is
> one
> > I may try to do soon.
> >
> > --
> > Jeremy Thomerson
> > http://www.wickettraining.com
> >
> >
> >
> > On Wed, Apr 8, 2009 at 4:36 PM, Juan G. Arias <juangar...@gmail.com>
> wrote:
> >
> >> Hi all,First of all, I'm using wicket 1.3.5
> >>
> >> I'm writing a model and ai need it to be "chaineable". I mean, I need
> this
> >> model to contain another model, so my model can obtain the data, for
> >> example, from a property model.
> >> Ok, I've been reading and this is solved by the IChainingModel.
> >>
> >> But I couldn't find any default implementation of this interface.
> >> There are two classes currently implementing this interface,
> >> AbstractPropertyModel and CompoundPropertyModel.
> >> Both classes has some code duplicated, specifically:
> >> - void detach()
> >> - IModel getChainedModel()
> >> - void setChainedModel(IModel model)
> >> - some lines of void setObject(Object object)
> >> - the code in CompuntPropertyModel#getObject() and
> >> AbstarctPropertyModel#getTarget() is different, but the logic is the
> same.
> >>
> >> And I'm afraid my code will be the same as those classes.
> >>
> >> So, finally, my point.
> >> Is there any default implementation of this behavior? Is there a chance
> to
> >> add a super-class with this code?
> >>
> >> Thanks!
> >> Juan Arias
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to