Oooops, in case some of you are baffled that this code would work, let me
put your mind at ease, it doesn't. :o)

I overlooked the fact that a plain Model does not have the ability to chain
another Model. (ie a constructor accepting another Model)
So the code sample I gave wouldn't work, in my real code I actually used a
CompoundPropertyModel, which does have this ability, so it worked for me.

If you don't want to use CompoundPropertyModel you can still use the code
below, but you'll have to use an implementation of IChainingModel instead of
a plain Model.

Kind regards,
Stijn


2010/1/5 Stijn Maller <stijn.mal...@gmail.com>

> Hi Janning,
>
> That's definately better then exposing the form, but it still makes me have
> to insert an extra methodcall everywhere I update the modelobject. Here's
> what I implemented a couple of seconds ago and it seems to be doing what I
> wanted just fine, and no listener needed either.
>
> Instead of:
>
> Form detailForm = new Form("detailForm", model);
>
> I do:
> Form detailForm = new Form("detailForm");
> IModel wrappingModel = new Model(model) {
>             private Object previousModelObject = null;
>
>             @Override
>             public Object getObject() {
>                 if (previousModelObject != super.getObject()) {
>                     detailForm.modelChanged();
>                     previousModelObject = super.getObject();
>                 }
>                 return super.getObject();
>             }
>         };
> }
> detailForm.setModel(wrappingModel);
>
>
> 2010/1/5 Janning Vygen <vy...@kicktipp.de>
>
>
>> your "master" knows about your "detail" panel. so why don't you call
>> detail.modelChanged();
>>
>> and in your DetailPanel:
>>
>> onModelChanged() {
>>  form.modelChanged(); // or whatever is needed...
>>  form.clearInput();
>>  super.onModelChanged()
>> }
>>
>> Your form is still managed by your detail panel only.
>>
>> kind regards
>> Janning
>>
>> On Tuesday 05 January 2010 11:03:59 Stijn Maller wrote:
>> > Thanks Martin,
>> >
>> > You're right, a Model that calls ModelObjectChangedListener is basically
>> > what I am looking for, but I don't think it exists. I'll write one
>> myself,
>> > but I just wanted to check first to make sure I wasn't reinventing the
>> > wheel or missing something obvious.
>> >
>> > Kind regards,
>> > Stijn
>> >
>> >
>> > 2010/1/4 Martin Makundi <martin.maku...@koodaripalvelut.com>
>> >
>> > > Hi!
>> > >
>> > > clearinput is right.  don't know if there is a IModel that has change
>> > > listener, but sure you can make your own that detects when the master
>> >
>> > changes. You need to repaint the components anyways
>> >
>> > > (target.addComponents), so why not clear input at the same time?
>> > >
>> > > **
>> > > Martin
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>

Reply via email to