Re: Wicket Model - A very simple question

2007-10-22 Thread Eelco Hillenius
  You only need models when you have something to display (and possibly
  receive)

 I see..so how would you comment on a component like label (just came across
 this example) where you still want to display something but can go ahead
 without the usage of model like add(new Label(message,Hello
 World))...

That's a convenience constructor for the common case that you want to
display text you know at construction time and that you don't expect
to change with next renderings. Here is the implementation of that
constructor:

public Label(final String id, String label)
{
this(id, new Model(label));
}

As you can see - and as the Java docs tell ('Convenience constructor.
Same as Label(String, new Model(String))'), a model is implicitly
constructed.

 so one cant just make clear distinction as to where to use a
 model where not (i mean i know by looking at the component api one certainly
 can determine)..

It's really one of the rare exceptions. Using models are the rule. It
is often when you create your own components that you may decide to go
another route.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread mfs

makes sense...

Thanks .

Farhan.


mfs wrote:
 
 Guys,
 
 
 Would sound like a very naive question, actually still in the process of
 understand the different concepts in wicket, Wicket Models in this
 particular case...so my question is 
 
 Wouldn't the below two statements act exactly the same given i have a
 person object (which i would say both acts as a model as well as an object
 to which the form data is submitted) defined in a page.
 
 add(new RequiredTextField(person.userName));
 add(new RequiredTextField(person.userName),new
 PropertyModel(person,username));
 
 If TRUE, the only reason i would want to have a PropertyModel (or in other
 words any type of Model) against a page-component would be the scenario
 where the object i want to use as model is different from the one i would
 use for data-submission...Correct..?
 
 Thanks in advance and Regards,
 
 Farhan.
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Wicket-Model---A-very-simple-question-tf4668214.html#a13337387
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Johan Compagner

 Nope. Typical reasons to use PropertyModels explicitly is when you
 don't use a CompoundPropertyModel on the parent, or when you want to
 use IDs that are different from the property expressions you want the
 model to work on. Also, note that you can use completely different
 models as well; property models are convenient but not the only
 options (as you can read in the WIKI).



CompoundPropertyModel  cpm = new CompoundPropertyModel (xxx);
Form f = new Form(form,cpm);
f.add(new TextField(username));
f.add(new TextField(notinmodel, cpm.bind(address));


Re: Wicket Model - A very simple question

2007-10-22 Thread Eelco Hillenius
 CompoundPropertyModel  cpm = new CompoundPropertyModel (xxx);
 Form f = new Form(form,cpm);
 f.add(new TextField(username));


 f.add(new TextField(notinmodel, cpm.bind(address));

Yes, that is another alternative to using property model. I didn't
mention this since it only complicates things. I'm not crazy about the
facility anyway.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Johan Compagner
complicates? its only a much smaller notation for creating a property model
And i think it reads very well.

What would be better then something reversed?

cpm.bind(textField,address)
?

But then you have to first have a reference.to the textfield.
We had such a thing in wicket 1.1 (BoundedCompoundPropertyModel)
But i think the current way is way better and nicer.

johan



On 10/22/07, Eelco Hillenius [EMAIL PROTECTED] wrote:

  CompoundPropertyModel  cpm = new CompoundPropertyModel (xxx);
  Form f = new Form(form,cpm);
  f.add(new TextField(username));


  f.add(new TextField(notinmodel, cpm.bind(address));

 Yes, that is another alternative to using property model. I didn't
 mention this since it only complicates things. I'm not crazy about the
 facility anyway.

 Eelco

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Wicket Model - A very simple question

2007-10-22 Thread Eelco Hillenius
On 10/22/07, Johan Compagner [EMAIL PROTECTED] wrote:
 complicates? its only a much smaller notation for creating a property model
 And i think it reads very well.

Yes, but in this particular case it doesn't let people understand
better what goes on.

 What would be better then something reversed?

 cpm.bind(textField,address)
 ?

 But then you have to first have a reference.to the textfield.
 We had such a thing in wicket 1.1 (BoundedCompoundPropertyModel)
 But i think the current way is way better and nicer.

I don't disagree with it. I just think that using property model is
nicer because you don't need to access the parent model (which you may
or may not have direct access to). Also, I was trying to explain the
difference between property model and compoundproperty model. Of
course, you can write a book on in how many other ways you can do the
same thing.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Martijn Dashorst
On 10/22/07, Eelco Hillenius [EMAIL PROTECTED] wrote:
 Of course, you can write a book on in how many other ways you can do the
 same thing.

I thought we already did :P

Martijn

-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Johan Compagner
just go back to that chapter and redo it!



On 10/22/07, Martijn Dashorst [EMAIL PROTECTED] wrote:

 On 10/22/07, Eelco Hillenius [EMAIL PROTECTED] wrote:
  Of course, you can write a book on in how many other ways you can do the
  same thing.

 I thought we already did :P

 Martijn

 --
 Buy Wicket in Action: http://manning.com/dashorst
 Apache Wicket 1.3.0-beta4 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Wicket Model - A very simple question

2007-10-22 Thread Martijn Dashorst
AGAIN? AARGH!!!

/me points gun to head


On 10/22/07, Johan Compagner [EMAIL PROTECTED] wrote:
 just go back to that chapter and redo it!



 On 10/22/07, Martijn Dashorst [EMAIL PROTECTED] wrote:
 
  On 10/22/07, Eelco Hillenius [EMAIL PROTECTED] wrote:
   Of course, you can write a book on in how many other ways you can do the
   same thing.
 
  I thought we already did :P
 
  Martijn
 
  --
  Buy Wicket in Action: http://manning.com/dashorst
  Apache Wicket 1.3.0-beta4 is released
  Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 



-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread mfs

LOL...anyways guys i must say that you are doing a great job on this forum,
yet to read your book though..

Farhan.



Martijn Dashorst wrote:
 
 AGAIN? AARGH!!!
 
 /me points gun to head
 
 
 On 10/22/07, Johan Compagner [EMAIL PROTECTED] wrote:
 just go back to that chapter and redo it!



 On 10/22/07, Martijn Dashorst [EMAIL PROTECTED] wrote:
 
  On 10/22/07, Eelco Hillenius [EMAIL PROTECTED] wrote:
   Of course, you can write a book on in how many other ways you can do
 the
   same thing.
 
  I thought we already did :P
 
  Martijn
 
  --
  Buy Wicket in Action: http://manning.com/dashorst
  Apache Wicket 1.3.0-beta4 is released
  Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 
 
 -- 
 Buy Wicket in Action: http://manning.com/dashorst
 Apache Wicket 1.3.0-beta4 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Wicket-Model---A-very-simple-question-tf4668214.html#a13353307
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Martijn Dashorst
On 10/22/07, mfs [EMAIL PROTECTED] wrote:
 LOL...anyways guys i must say that you are doing a great job on this forum,
 yet to read your book though..

The book is even better. You don't have to listen to Igor and Johan in it :-)

Martijn

-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Johan Compagner
and miss all the fun. how boring will the book be i asked my self now.

On 10/22/07, Martijn Dashorst [EMAIL PROTECTED] wrote:

 On 10/22/07, mfs [EMAIL PROTECTED] wrote:
  LOL...anyways guys i must say that you are doing a great job on this
 forum,
  yet to read your book though..

 The book is even better. You don't have to listen to Igor and Johan in it
 :-)

 Martijn

 --
 Buy Wicket in Action: http://manning.com/dashorst
 Apache Wicket 1.3.0-beta4 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Wicket Model - A very simple question

2007-10-22 Thread Eelco Hillenius
On 10/22/07, Johan Compagner [EMAIL PROTECTED] wrote:
 and miss all the fun. how boring will the book be i asked my self now.

You mean you didn't start reading it yet?!

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Igor Vaynberg
must be a pretty serious book, no comic relief at all? no smartass
comments? i wont buy it!

-igor


On 10/22/07, Martijn Dashorst [EMAIL PROTECTED] wrote:
 On 10/22/07, mfs [EMAIL PROTECTED] wrote:
  LOL...anyways guys i must say that you are doing a great job on this forum,
  yet to read your book though..

 The book is even better. You don't have to listen to Igor and Johan in it :-)

 Martijn

 --
 Buy Wicket in Action: http://manning.com/dashorst
 Apache Wicket 1.3.0-beta4 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Eelco Hillenius
On 10/22/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
 must be a pretty serious book, no comic relief at all? no smartass
 comments? i wont buy it!

It's not too late for a few quotes of you. Maybe you could write the
intro's of the chapters? :-)

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-22 Thread Dirk Markert
2007/10/23, Eelco Hillenius [EMAIL PROTECTED]:

 On 10/22/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
  must be a pretty serious book, no comic relief at all? no smartass
  comments? i wont buy it!

 It's not too late for a few quotes of you. Maybe you could write the
 intro's of the chapters? :-)


+1

Dirk


Re: Wicket Model - A very simple question

2007-10-22 Thread Igor Vaynberg
lol, nice try :) you aint offloading any of this writing fun on me :)

-igor


On 10/22/07, Eelco Hillenius [EMAIL PROTECTED] wrote:
 On 10/22/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
  must be a pretty serious book, no comic relief at all? no smartass
  comments? i wont buy it!

 It's not too late for a few quotes of you. Maybe you could write the
 intro's of the chapters? :-)

 Eelco

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-21 Thread Eelco Hillenius

 Wouldn't the below two statements act exactly the same given i have a person
 object (which i would say both acts as a model as well as an object to which
 the form data is submitted) defined in a page.

 add(new RequiredTextField(person.userName));
 add(new RequiredTextField(person.userName),new
 PropertyModel(person,username));

That is only true if you set a CompoundPropertyModel on the parent (or
one of the parent's parents). Btw, you'd likely let the person be the
subject of either the Propertymodel or CompoundPropertyModel.

 If TRUE, the only reason i would want to have a PropertyModel (or in other
 words any type of Model) against a page-component would be the scenario
 where the object i want to use as model is different from the one i would
 use for data-submission...Correct..?

Nope. Typical reasons to use PropertyModels explicitly is when you
don't use a CompoundPropertyModel on the parent, or when you want to
use IDs that are different from the property expressions you want the
model to work on. Also, note that you can use completely different
models as well; property models are convenient but not the only
options (as you can read in the WIKI).

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-21 Thread mfs

Eelco,

Appreciate the quick follow up, so would it be OK to assume that every
page-component has to have a Model associated with it, either the model is
individually explicitly tagged with a component e.g. add(new
RequiredTextField(dateOfBirth, new PropertyModel(person, dateOfBirth)))
OR it using the model configured for its parent (which lets say could be the
form or the page) via CompoundPropertyModel where you normally don't require
using the PropertyModel unless the need comes (as you commented, though i
have some question below on it)Correct ?

Also on your comment on the usage of PropertyModels where you said ...when
you want to
use IDs that are different from the property expressions you want the model
to work on, i assume that you are refering to a scenario where you are
using a CompoundPropertyModel but you require the component to be populated
from a different source other than the model set for the parent..e.g.
add(new RequiredTextField (login.userName),new
PropertyModel(person,username));

Thanks again and REgards,

Farhan.



Eelco Hillenius wrote:
 

 Wouldn't the below two statements act exactly the same given i have a
 person
 object (which i would say both acts as a model as well as an object to
 which
 the form data is submitted) defined in a page.

 add(new RequiredTextField(person.userName));
 add(new RequiredTextField(person.userName),new
 PropertyModel(person,username));
 
 That is only true if you set a CompoundPropertyModel on the parent (or
 one of the parent's parents). Btw, you'd likely let the person be the
 subject of either the Propertymodel or CompoundPropertyModel.
 
 If TRUE, the only reason i would want to have a PropertyModel (or in
 other
 words any type of Model) against a page-component would be the scenario
 where the object i want to use as model is different from the one i would
 use for data-submission...Correct..?
 
 Nope. Typical reasons to use PropertyModels explicitly is when you
 don't use a CompoundPropertyModel on the parent, or when you want to
 use IDs that are different from the property expressions you want the
 model to work on. Also, note that you can use completely different
 models as well; property models are convenient but not the only
 options (as you can read in the WIKI).
 
 Eelco
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Wicket-Model---A-very-simple-question-tf4668214.html#a13336961
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-21 Thread Eelco Hillenius
 Appreciate the quick follow up, so would it be OK to assume that every
 page-component has to have a Model associated with it,

You only need models when you have something to display (and possibly
receive) and use components that use models (which is the case for
most components we ship, but doesn't always have to be the case).

 either the model is
 individually explicitly tagged with a component e.g. add(new
 RequiredTextField(dateOfBirth, new PropertyModel(person, dateOfBirth)))
 OR it using the model configured for its parent (which lets say could be the
 form or the page) via CompoundPropertyModel where you normally don't require
 using the PropertyModel unless the need comes (as you commented, though i
 have some question below on it)Correct ?

Correct. You typically use CompoundPropertyModels where you want
display or edit a bunch of properties of an object. Using
CompoundPropertyModels makes for shorter code.

 Also on your comment on the usage of PropertyModels where you said ...when
 you want to
 use IDs that are different from the property expressions you want the model
 to work on, i assume that you are refering to a scenario where you are
 using a CompoundPropertyModel but you require the component to be populated
 from a different source other than the model set for the parent..e.g.
 add(new RequiredTextField (login.userName),new
 PropertyModel(person,username));

Yeah. Like with add(new TextField(someRandomComponentId, new
PropertyModel(person, firstName));

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket Model - A very simple question

2007-10-21 Thread mfs

 You only need models when you have something to display (and possibly
 receive) 

I see..so how would you comment on a component like label (just came across
this example) where you still want to display something but can go ahead
without the usage of model like add(new Label(message,Hello
World))...so one cant just make clear distinction as to where to use a
model where not (i mean i know by looking at the component api one certainly
can determine)..

Thanks again.

Farhan.


 Correct. You typically use CompoundPropertyModels where you want
 display or edit a bunch of properties of an object. Using
 CompoundPropertyModels makes for shorter code.

 Also on your comment on the usage of PropertyModels where you said
 ...when
 you want to
 use IDs that are different from the property expressions you want the
 model
 to work on, i assume that you are refering to a scenario where you are
 using a CompoundPropertyModel but you require the component to be
 populated
 from a different source other than the model set for the parent..e.g.
 add(new RequiredTextField (login.userName),new
 PropertyModel(person,username));

Yeah. Like with add(new TextField(someRandomComponentId, new
PropertyModel(person, firstName));

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
View this message in context: 
http://www.nabble.com/Wicket-Model---A-very-simple-question-tf4668214.html#a13337090
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]