That's not a bad idea at all. Thanks!
On Fri, 2007-03-16 at 08:55 +0000, Gwyn Evans wrote:
> Hi,
> (If Igor says anything different, just ignore this! :-))
>
> The change that I'd consider would the standard one of if it'd be
> worth passing in a custom IMyBean interface derived from IModel, to
> cover the case where I might want to use something like-but-not-a
> MyBean, but I can't see anything wrong with passing it directly if
> that's not the case.
>
> /Gwyn
>
> On 16/03/07, David Leangen <[EMAIL PROTECTED]> wrote:
> >
> > Ok, thanks for the info.
> >
> > Sorry for not letting this thread die... but one more question (and
> > hopefully last):
> >
> > Right now, the page I refactored looks like this:
> >
> > MyPage page = new MyPage( MyBean bean )
> > {
> > SomeComponent component = new Component( "id", new MyModel( bean ) );
> > bla bla
> > Hi, Mom
> > }
> >
> >
> > So, I'm injecting my bean, as is, into the constructor of the page. The
> > bean is created somewhere else. In the MyModel above, I'm actually using
> > a field of a field of the model, so I get:
> >
> > class MyModel implements IModel
> > {
> > private MyThing thing;
> >
> > public MyModel( MyBean bean )
> > {
> > this.thing = bean.getField().getThing();
> > }
> >
> > More bla bla
> > }
> >
> >
> > So:
> >
> > Is it "ok" to pass in the raw bean into the page contructor, or should I
> > be passing in a model instead?
> >
> > Is there an even better way to go about all this that I haven't noticed?
> >
> >
> > In any case, what I do really like about IModel is that it gives a
> > direct translation between the controls and my bean. So cool!
> >
> >
> > Cheers,
> > David
> >
> >
> >
> > On Thu, 2007-03-15 at 07:27 -0800, Igor Vaynberg wrote:
> > > it is mostly internal and will be removed in the coming model refactor
> > >
> > > -igor
> > >
> > >
> > > On 3/14/07, David Leangen <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Ok, thanks for your help, guys. I finally figured out what you
> > > meant by
> > > your last comments, and implemented one way to go about this.
> > > Not sure
> > > if it's the "best" way, but it's certainly much cleaner than
> > > before.
> > >
> > > Thanks!!
> > >
> > > Just one question remaining.
> > >
> > > What's the deal with getNestedModel( )?
> > >
> > > It sounds useful, but that never gets invoked.
> > >
> > >
> > > What is it for, and how would I use it?
> > >
> > >
> > > Cheers,
> > > Dave
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Tue, 2007-03-13 at 16:07 +0900, David Leangen wrote:
> > > > :-)
> > > >
> > > > > if you disable a formcomponent then neither a set or get
> > > will be
> > > > > called
> > > >
> > > >
> > > > Yes. But it's not disabled, and get is being called. Just
> > > not set.
> > > >
> > > > I must be doing something wrong or missing something in the
> > > impl here...
> > > > but I don't see what it is. :-(
> > > >
> > > >
> > > > Cheers,
> > > > Dave
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > > Sorry for pulling you guys back to my mail
> > > issue. ;-)
> > > > >
> > > > > Since setObject() is not being called, I don't see
> > > how to
> > > > > apply my
> > > > > complex model to its children. I thought I could
> > > pull this off
> > > > > with
> > > > > setModel()... but it just ain't being called.
> > > > >
> > > > >
> > > > > Ok, let's stick with the "person" object. The
> > > person has
> > > > > attributes, and
> > > > > one of these attributes may itself have
> > > attributes.
> > > > >
> > > > > For example:
> > > > >
> > > > > Person:
> > > > > isSingle?
> > > > >
> > > > > if( isSingle )
> > > > >
> > > > > [ ] does dishes?
> > > > > [ ] makes bed?
> > > > >
> > > > > else
> > > > >
> > > > > [ ] has kids?
> > > > > [ ] walks dog?
> > > > >
> > > > > Whatever.
> > > > >
> > > > > Point is, if the isSingle attribute is "true", I
> > > want to
> > > > > enable certain
> > > > > checkboxes and bind those values DIRECTLY to the
> > > model. Same
> > > > > goes if
> > > > > isSingle is false.
> > > > >
> > > > > Right now, I collect a boolean for each value and
> > > set them
> > > > > back
> > > > > "manually" into my model, which seems really
> > > messy.
> > > > >
> > > > > Same thing for enabling/disabling my checkboxes
> > > above: I do
> > > > > that
> > > > > "manually" depending on the current value in the
> > > model.
> > > > >
> > > > >
> > > > > What I'd really like to do is somehow bind all
> > > those controls
> > > > > directly
> > > > > to my model so I'm not duplicating parts of the
> > > model for each
> > > > > control.
> > > > >
> > > > >
> > > > > Any hints that would enlighten me on how to do
> > > this?
> > > > >
> > > > >
> > > > > Thanks so much!!
> > > > >
> > > > >
> > > > >
> > > > > On Mon, 2007-03-12 at 22:58 -0700, Eelco Hillenius
> > > wrote:
> > > > > > Maybe it is good to gather a couple of use cases
> > > and pros
> > > > > and cons and
> > > > > > start a separate thread?
> > > > > >
> > > > > > Eelco
> > > > > >
> > > > > > On 3/12/07, Igor Vaynberg
> > > <[EMAIL PROTECTED]> wrote:
> > > > > > > ah, but if you modify a collection that is a
> > > model object
> > > > > are you infact
> > > > > > > "changing" the object? you are not changing
> > > the reference
> > > > > itself but you are
> > > > > > > doing something that has sideffects.
> > > > > > >
> > > > > > > eg lets say you have a dropdown choice, but
> > > what you want
> > > > > is a collection of
> > > > > > > ids not the objects. the easiest way is to
> > > have a model in
> > > > > between that
> > > > > > > translates a collection of objects to ids and
> > > back again.
> > > > > but how to do that
> > > > > > > if setobject() is never called?
> > > > > > >
> > > > > > > -igor
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On 3/12/07, Eelco Hillenius <
> > > [EMAIL PROTECTED]>
> > > > > wrote:
> > > > > > > >
> > > > > > > > If you are not changing the object that is
> > > the subject
> > > > > of the model, I
> > > > > > > > see no reason why setObject should be
> > > called.
> > > > > > > >
> > > > > > > > Eelco
> > > > > > > >
> > > > > > > > On 3/12/07, Igor Vaynberg
> > > <[EMAIL PROTECTED] >
> > > > > wrote:
> > > > > > > > > actually we are inconsistent in some
> > > places and i have
> > > > > been trying to
> > > > > > > fix
> > > > > > > > > it. what we mostly do is whenever we work
> > > with a
> > > > > collection we clear it
> > > > > > > and
> > > > > > > > > repopulate it. but we never call
> > > setobject() on the
> > > > > model which imho is
> > > > > > > > > wrong. sometimes i have a model in between
> > > that
> > > > > depends on setobject()
> > > > > > > > > called whenever a property is updated
> > > because it does
> > > > > some translation
> > > > > > > and
> > > > > > > > > its a lot easier to proxy a model then it
> > > is to proxy
> > > > > a collection. just
> > > > > > > my
> > > > > > > > > 2c.
> > > > > > > > >
> > > > > > > > > -igor
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 3/12/07, Eelco Hillenius
> > > > > <[EMAIL PROTECTED]> wrote:
> > > > > > > > > >
> > > > > > > > > > > > > now all you have to do is
> > > > > > > > > > > > >
> > > > > > > > > > > > > LoadableDetachableModel
> > > person=new
> > > > > LoadalbeDetachableModel(id);
> > > > > > > > > > > > > new CheckBox(this, "cb", new
> > > > > PersonCheckBoxModel(person));
> > > > > > > > > > > > >
> > > > > > > > > > > > > and everything magically works,
> > > hope it gives
> > > > > you some ideas.
> > > > > > > > > > >
> > > > > > > > > > > Yes, it does indeed give me many
> > > ideas. Right now,
> > > > > I'm trying to
> > > > > > > figure
> > > > > > > > > > > out the implementation details.
> > > > > > > > > > >
> > > > > > > > > > > While stepping through the code, I
> > > noticed that
> > > > > the setObject()
> > > > > > > method
> > > > > > > > > > > of my IModel never gets called.
> > > > > > > > > > >
> > > > > > > > > > > When is this _supposed_ to be set, and
> > > why would
> > > > > it not be called in
> > > > > > > my
> > > > > > > > > > > case?
> > > > > > > > > >
> > > > > > > > > > There's not always a need for setObject
> > > to be
> > > > > called. I haven't read
> > > > > > > > > > the whole thread, but in the above
> > > example, you work
> > > > > on a property
> > > > > > > > > > ('cb') of the person, so all you have to
> > > do
> > > > > (probably) is do something
> > > > > > > > > > with this updated object (like saving
> > > it). You would
> > > > > only do setObject
> > > > > > > > > > when you would provide a new person, and
> > > when the
> > > > > getObject
> > > > > > > > > > implementation wouldn't take care of
> > > that.
> > > > > > > > > >
> > > > > > > > > > Personally, I rarely use/ depend on
> > > setObject as
> > > > > working with
> > > > > > > > > > properties of objects is a very typical
> > > thing to
> > > > > do.
> > > > > > > > > >
> > > > > > > > > > Hope this makes sense,
> > > > > > > > > >
> > > > > > > > > > Eelco
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user