Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-16 Thread David Leangen

That's not a bad idea at all. Thanks!



On Fri, 2007-03-16 at 08:55 +, 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 a

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-16 Thread Gwyn Evans
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.
> > > >
> > > >
> > > >

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-15 Thread David Leangen

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: 
> > > >

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-14 Thread David Leangen


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
> >  

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread David Leangen

:-)

> 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
>

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Igor Vaynberg

if you disable a formcomponent then neither a set or get will be called

-igor


On 3/12/07, David Leangen <[EMAIL PROTECTED]> wrote:



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
> > > > > Wicket-user@lists.sourceforge.net
> > > > >
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > > >
> >

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread David Leangen

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
> > > > > Wicket-user@lists.sourceforge.net
> > > > >
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > > >
> > > >
> > > >
> > > >
> > -
> > > > Take Surveys. Earn Cash. Inf

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Eelco Hillenius
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
> > > > Wicket-user@lists.sourceforge.net
> > > >
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > >
> > >
> > >
> > >
> -
> > > 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
> > > Wicket-user@lists.sourceforge.net
> > >
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> > >
> >
> >
> -
> > 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
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
> -
> 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
> _

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Igor Vaynberg

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
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
>
-
> 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
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Eelco Hillenius
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
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
> -
> 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
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Igor Vaynberg

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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Eelco Hillenius
> > > 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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Igor Vaynberg

setobject is called when the component needs to update the model. eg when
you submit a textfield it needs to push new input into the model and so it
calls setobject(). sometimes components that work with collections do not do
that - they simply clear the collection and add new values - this is so you
are in control of creating the collection - be it a set/list/etc.

-igor


On 3/12/07, David Leangen <[EMAIL PROTECTED]> wrote:



Igor,

Regarding your suggestions below:

> > class mypage extends page {
> > private Set selected=new HashSet();
> >
> > private class PersonCheckboxModel implements IModel {
> > private final IModel person;
> > public final PersonCheckBoxModel(IModel person) {
> > this.person=person; }
> >
> > public Boolean getObject() {
> > return selected.contains(person.getObject());
> > }
> >
> > public void setObject(Boolean b) {
> > if (Boolean.TRUE.equals(b)) {
> > selected.put(person.getObject());
> > } else {
> > selected.remove(person.getObject());
> > }
> > }
> >
> > public void detach() { person.detach(); }
> > }
> >
> > }
> >
> > 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?


Cheers,
David





-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread David Leangen

Igor,

Regarding your suggestions below:

> > class mypage extends page {
> > private Set selected=new HashSet();
> >
> > private class PersonCheckboxModel implements IModel {
> > private final IModel person;
> > public final PersonCheckBoxModel(IModel person) {
> > this.person=person; }
> >
> > public Boolean getObject() {
> > return selected.contains(person.getObject());
> > }
> >
> > public void setObject(Boolean b) {
> > if (Boolean.TRUE.equals(b)) {
> > selected.put(person.getObject());
> > } else {
> > selected.remove(person.getObject());
> > }
> > }
> >
> > public void detach() { person.detach(); }
> > }
> >
> > }
> >
> > 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?


Cheers,
David





-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread David Leangen

Still playing around with this, and I have a question.

When does the IModel's setObject() method get called?

I'm stepping through the code, but this method is never being called...


Cheers,
Dave




On Fri, 2007-03-09 at 16:47 -0600, Thomas R. Corbin wrote:
> On Friday, 09 March 2007 11:57 am, Igor Vaynberg escreveu:
> > yes, but then you are married to the output it genereates.
> >
> > [] label
> > [] label
> >
> > whats below you can use just for the checkbox, so you are free to generate
> > your own label/panel/whatever. eg selecting rows in a table.
> 
>   Ooooh - thanks!
> 
> >
> > -igor
> >
> > On 3/9/07, Thomas R. Corbin <[EMAIL PROTECTED]> wrote:
> > > On Thursday, 08 March 2007 07:58 pm, Igor Vaynberg escreveu:
> > > > see above. take a simple example where you have a list of checkboxes
> > > > and you want all selected objects to end up in a collection. how do you
> > > > do
> > >
> > > it?
> > >
> > > > sounds like a complex mapping? the most elegant way is to write a
> > > > custom model.
> > >
> > > Can you use a CheckBoxMultipleChoice for this?
> > >
> > > > class mypage extends page {
> > > > private Set selected=new HashSet();
> > > >
> > > > private class PersonCheckboxModel implements IModel {
> > > > private final IModel person;
> > > > public final PersonCheckBoxModel(IModel person) {
> > > > this.person=person; }
> > > >
> > > > public Boolean getObject() {
> > > > return selected.contains(person.getObject());
> > > > }
> > > >
> > > > public void setObject(Boolean b) {
> > > > if (Boolean.TRUE.equals(b)) {
> > > > selected.put(person.getObject());
> > > > } else {
> > > > selected.remove(person.getObject());
> > > > }
> > > > }
> > > >
> > > > public void detach() { person.detach(); }
> > > > }
> > > >
> > > > }
> > > >
> > > > 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.
> > >
> > > -
> > > 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
> > > Wicket-user@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> -
> 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
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user


-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-09 Thread Thomas R. Corbin
On Friday, 09 March 2007 11:57 am, Igor Vaynberg escreveu:
> yes, but then you are married to the output it genereates.
>
> [] label
> [] label
>
> whats below you can use just for the checkbox, so you are free to generate
> your own label/panel/whatever. eg selecting rows in a table.

Ooooh - thanks!

>
> -igor
>
> On 3/9/07, Thomas R. Corbin <[EMAIL PROTECTED]> wrote:
> > On Thursday, 08 March 2007 07:58 pm, Igor Vaynberg escreveu:
> > > see above. take a simple example where you have a list of checkboxes
> > > and you want all selected objects to end up in a collection. how do you
> > > do
> >
> > it?
> >
> > > sounds like a complex mapping? the most elegant way is to write a
> > > custom model.
> >
> > Can you use a CheckBoxMultipleChoice for this?
> >
> > > class mypage extends page {
> > > private Set selected=new HashSet();
> > >
> > > private class PersonCheckboxModel implements IModel {
> > > private final IModel person;
> > > public final PersonCheckBoxModel(IModel person) {
> > > this.person=person; }
> > >
> > > public Boolean getObject() {
> > > return selected.contains(person.getObject());
> > > }
> > >
> > > public void setObject(Boolean b) {
> > > if (Boolean.TRUE.equals(b)) {
> > > selected.put(person.getObject());
> > > } else {
> > > selected.remove(person.getObject());
> > > }
> > > }
> > >
> > > public void detach() { person.detach(); }
> > > }
> > >
> > > }
> > >
> > > 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.
> >
> > -
> > 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
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-09 Thread Igor Vaynberg

yes, but then you are married to the output it genereates.

[] label
[] label

whats below you can use just for the checkbox, so you are free to generate
your own label/panel/whatever. eg selecting rows in a table.

-igor


On 3/9/07, Thomas R. Corbin <[EMAIL PROTECTED]> wrote:


On Thursday, 08 March 2007 07:58 pm, Igor Vaynberg escreveu:
> see above. take a simple example where you have a list of checkboxes and
> you want all selected objects to end up in a collection. how do you do
it?
> sounds like a complex mapping? the most elegant way is to write a custom
> model.

Can you use a CheckBoxMultipleChoice for this?

>
> class mypage extends page {
> private Set selected=new HashSet();
>
> private class PersonCheckboxModel implements IModel {
> private final IModel person;
> public final PersonCheckBoxModel(IModel person) {
> this.person=person; }
>
> public Boolean getObject() {
> return selected.contains(person.getObject());
> }
>
> public void setObject(Boolean b) {
> if (Boolean.TRUE.equals(b)) {
> selected.put(person.getObject());
> } else {
> selected.remove(person.getObject());
> }
> }
>
> public void detach() { person.detach(); }
> }
>
> }
>
> 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.

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-09 Thread Thomas R. Corbin
On Thursday, 08 March 2007 07:58 pm, Igor Vaynberg escreveu:
> see above. take a simple example where you have a list of checkboxes and
> you want all selected objects to end up in a collection. how do you do it?
> sounds like a complex mapping? the most elegant way is to write a custom
> model.

Can you use a CheckBoxMultipleChoice for this?

>
> class mypage extends page {
>   private Set selected=new HashSet();
>
>   private class PersonCheckboxModel implements IModel {
>         private final IModel person;
>         public final PersonCheckBoxModel(IModel person) {
> this.person=person; }
>
>        public Boolean getObject() {
>           return selected.contains(person.getObject());
>         }
>
>         public void setObject(Boolean b) {
>             if (Boolean.TRUE.equals(b)) {
>                selected.put(person.getObject());
>              } else {
>                 selected.remove(person.getObject());
>               }
>            }
>
>             public void detach() { person.detach(); }
>            }
>
>     }
>
> 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.

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-08 Thread Igor Vaynberg

On 3/8/07, David Leangen <[EMAIL PROTECTED]> wrote:



This is actually something I'm kinda struggling with.

In our model, the "biz logic" is the query. So, for instance, if I have
two radios and a group of checkboxes:

( ) Any colour
( ) Choose colours
  [ ] Blue
  [ ] Red
  ...



If "Any colour" is chosen, then this produces one kind of query (where

choosing colours is irrelevant). In that case, the checkboxes must be
disabled. However, if "Choose colours" is chosen, colours become
relevant, so the checkboxes are activated.

So, is this "biz" or "ui" logic?



the part that enables and disables components is ui logic. there is no need
to break that out into somewhere else.

the logic that validates the bean constructed by the ui is business logic.
but there are aguments to keep validation as close to the ui as possible
because its easier to map and is closest to the input - so that one is up
for grabs i suppose. this is why i decoupled validators in 2.0 - so
potentially you can use the exact same validator in your service layer and
in the ui layer.

Or, worded differently, does this go into the controller or directly

into the wicket component?



i would put this into the wicket component and call it a day. if you are
planning on having some other interface these beans can be constructed from
then i would consider some sort of validation in the controller.


it would be a good idea if you can initialize some state off the
> pageparameters, be that business state or ui state or both. that way
> you can retain bookmarkability.

Just to confirm:

We would not be _required_ to use PageParameters. Having a lightweight
bean would allow us to "save" the state of the bean in the model, and
therefore to the PageMap, right?



s/PageMap/session/

But, using PageParameters would give us the option of making pages

bookmarkable, right?



bookmarkable pages serve as entry points into the workflow, so if you need
that then yes, but it doesnt mean every page makes sense as an entry point.

In either case, this approach is still valid, so it seems.



Another question:

Say we do want to keep our pages bookmarkable, but we don't want to have
to encode everything in the URL. Say also we don't want to use a db on
the backend. Would it be appropriate to save the beans to the wicket
session?



if its not encoded in the url then where would it be encoded? as i said
bookmarkable pages are entry points so they need to contain all the
necessary state to initiate the workflow. and the only place for that is the
url.


If so:


  1. What is an elegant way of doing this? Just a Map(id, object)
 that is accessed by the controller?



i would write a converter that can do bean<->pageparameters

 2. Is there anything to watch out for? (Such as the map growing to

 an incredible size, for example)



if you keep things  scoped at a page and pass them from page to page you can
take advantage of wicket's state management so your state wont get too big.

-igor








> i think a lot of users underestimate the power of IModel when you
> implement it directly.




> 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.

Very interesting!

I'll have to give this a try.


Thanks again!
Dave





-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-08 Thread David Leangen

Great! Thanks for this. Very helpful!

This does give a lot of ideas, indeed. If my understanding is correct,
this would indeed provide a very elegant solution to what we're trying
to do.

One precision:


> you have to decide what is clearly "business logic" vs "ui logic". the
> business logic should go into a separate
> service/controller/whatchamaggicit. the ui logic is best embedded in
> wicket components because each component is a full implementation of
> MVC already. 

This is actually something I'm kinda struggling with.

In our model, the "biz logic" is the query. So, for instance, if I have
two radios and a group of checkboxes:

( ) Any colour
( ) Choose colours
  [ ] Blue
  [ ] Red
  ...

If "Any colour" is chosen, then this produces one kind of query (where
choosing colours is irrelevant). In that case, the checkboxes must be
disabled. However, if "Choose colours" is chosen, colours become
relevant, so the checkboxes are activated.

So, is this "biz" or "ui" logic?

Or, worded differently, does this go into the controller or directly
into the wicket component?


> it would be a good idea if you can initialize some state off the
> pageparameters, be that business state or ui state or both. that way
> you can retain bookmarkability. 

Just to confirm:

We would not be _required_ to use PageParameters. Having a lightweight
bean would allow us to "save" the state of the bean in the model, and
therefore to the PageMap, right?

But, using PageParameters would give us the option of making pages
bookmarkable, right?


In either case, this approach is still valid, so it seems.


Another question:

Say we do want to keep our pages bookmarkable, but we don't want to have
to encode everything in the URL. Say also we don't want to use a db on
the backend. Would it be appropriate to save the beans to the wicket
session?

If so:

  1. What is an elegant way of doing this? Just a Map(id, object)
 that is accessed by the controller?

  2. Is there anything to watch out for? (Such as the map growing to
 an incredible size, for example)



> 
> i think a lot of users underestimate the power of IModel when you
> implement it directly.




> 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.

Very interesting!

I'll have to give this a try.


Thanks again!
Dave





-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-08 Thread Igor Vaynberg

here are my short answers :) ask more if you need something explained in
detail

On 3/8/07, David Leangen <[EMAIL PROTECTED]> wrote:



First Question: Controller Logic


The idea sounds good, but I'm wondering if this is even necessary. It
was suggested to me that cleanly separating stuff into a controller is
not worth the effort, since we'd be "duplicating" so much code for no
good reason.



you have to decide what is clearly "business logic" vs "ui logic". the
business logic should go into a separate service/controller/whatchamaggicit.
the ui logic is best embedded in wicket components because each component is
a full implementation of MVC already.



Also, say if we wanted to make the component compatible with
"bookmarkability", would it be a good idea to have a setter or
constructor in the controller that accepts something similar to
PageParameters, so wicket can just pass through that object to the
controller?



it would be a good idea if you can initialize some state off the
pageparameters, be that business state or ui state or both. that way you can
retain bookmarkability.

Second Question: Mapping Above Model to Wicket Models

-

1. How do we connect the wicket model with our controller
   above when validating the state and delegating to the
   state-holder bean?



i think a lot of users underestimate the power of IModel when you implement
it directly. you  dont have to use the default Model or PropertyModel, you
are just boxing yourself in. implement the interface yourself for most
flexibility - that way you can achieve any kind of mapping.

also do not underestimate the power of decorator/adapter pattern when it
comes to models.

2. How do we "associate" parts of the state-holder bean

   with the wicket controls? For example, the "blue"
   above needs a checkbox, so how do we associate the
   value of blue in our bean above to the "blue" checkbox?



see above. take a simple example where you have a list of checkboxes and you
want all selected objects to end up in a collection. how do you do it?
sounds like a complex mapping? the most elegant way is to write a custom
model.

class mypage extends page {
 private Set selected=new HashSet();

 private class PersonCheckboxModel implements IModel {
   private final IModel person;
   public final PersonCheckBoxModel(IModel person) {
this.person=person; }

  public Boolean getObject() {
 return selected.contains(person.getObject());
   }

   public void setObject(Boolean b) {
   if (Boolean.TRUE.equals(b)) {
  selected.put(person.getObject());
} else {
   selected.remove(person.getObject());
 }
  }

   public void detach() { person.detach(); }
  }

   }

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.

-igor



Hope my ramblings make some sense.




Cheers,
Dave





-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] Design questions: Use of controllers and wicket models

2007-03-08 Thread David Leangen

Hi!

Two design questions for experienced wicket users... Mail is a bit long.
I apologise for this, but I wanted to explain the situation well.

We have been using wicket now for a while, and I think it's time to try
to finally clean up our code a little. With that in mind, I have two
questions for more experienced users. First is about where to put logic,
second is about use of compound wicket models.


Background
--

Let me begin by describing our model briefly.

We have a search engine that allows certain "controlled" queries, and we
have a model/controller to accompany the wicket component(s) for this. 

Our idea is:

 - extract the state only into a very simple, serializable bean
 - use a controller to validate and control what state the
   bean can be in
 - "write" the state of the bean (query) in various formats
   through the use of a QueryWriter object
 - obviously use wicket component to allow user to set state


Our reasoning is:

1. Having a very simple and serializable bean will make it easy 
   to save the state either in a wicket session or in the backend. 
   The object should therefore be very lightweight.

2. Ideally NO logic should be in the wicket component. This is because:

   a. Logic should not be in the view
   b. Encapsulated logic can be reused (for example if we implement 
  in Swing)

3. Having a separate writer is a nice way to decouple the rendering
   of the state of the bean and seems to work very well.


Our model ends up being a complex bean that looks something like this:


public class QueryObject
implements Serializable
{
private ChildQueryObject m_colors;
private ChildQueryObject m_dates;
...

// Getters and setters here
// No logic! Very simple
}

And each "child" query object above can look something like this:

public class ColorQueryObject
implements Serializable
{
private boolean m_isBlueSelected;
private boolean m_isRedSelected;
...

public void setBlueSelected( boolean isSelected)
{
m_isBlueSelected = isSelected;
}

...
}

... you get the idea.


As stated above, the idea is that these beans hold only the state, and
nothing more. The query is "printed" by the user of a QueryWriter, which
I won't get into here.


This all looks fine at first glance, but when we get into the details,
we are scratching our heads about a few issues, wondering which would be
the "best" way to move forward.



First Question: Controller Logic


The idea of the controller is to control which states are valid, and
which are not. The original idea is that the wicket ui components can
only put the beans into a given state by using this controller. The
reason is that I don't like having too much logic in the ui classes.

If we do this, it looks like it means a lot of duplication of code,
since wicket will simply be delegating to the controller. For example:

In the wicket page, we'd have something like:

  controller.setBlueChecked( isBlueChecked );

And in the controller:

  public void setBlueChecked( boolean isChecked )
  {
  // validate if blue can be checked in this state
  // set the value, and adjust state of other
  //   properties if necessary

  // If it can't, what do we do? Throw an exception?
  }  


The idea sounds good, but I'm wondering if this is even necessary. It
was suggested to me that cleanly separating stuff into a controller is
not worth the effort, since we'd be "duplicating" so much code for no
good reason.



What do most people do to achieve clean code in this type of situation?

Also, say if we wanted to make the component compatible with
"bookmarkability", would it be a good idea to have a setter or
constructor in the controller that accepts something similar to
PageParameters, so wicket can just pass through that object to the
controller?



Second Question: Mapping Above Model to Wicket Models
-

Since the model above is already established, I presume that we should
just be able to do something like:

  IModel model = new Model( bean );

So now, the above bean is "wicketized".

However, two things I do not understand about this are:

1. How do we connect the wicket model with our controller 
   above when validating the state and delegating to the 
   state-holder bean?

2. How do we "associate" parts of the state-holder bean
   with the wicket controls? For example, the "blue" 
   above needs a checkbox, so how do we associate the
   value of blue in our bean above to the "blue" checkbox?


Hope my ramblings make some sense.



Cheers,
Dave





-
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=DEVD