public TextField(String id) {
    this(id, new Model());
}

Because then the model is not /null/ and the component will not try to search up its hierarchy to try to find a compound model which is a very important behaviour.

you can argue that we can try doing that if the value object obtained by model.getObject() is null, but then how can we tell the difference in case null is a legal value of the value object.

so in this case:
Form f=new Form("form", new CompoundPropertyModel(new Person()));
f.add(new TextField("address.city"));
we havent passed in a model for the textfield on purpose. because it is null the textfield will actually be connected to address.city property of the person object used as the value object of the form. this is described in the link i gave you previously.

-Igor



On 1/20/06, Rosenstrauch, David <[EMAIL PROTECTED]> wrote:
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Igor Vaynberg
Sent: Friday, January 20, 2006 1:37 PM
To: [email protected]
Subject: Re: [Wicket-user] RE: span tag clarification

there are a couple of reasons for this.

1) there is really no good way for a component to assign a model to itself. the model is itself simply a locator for a value object that is used by the component. since form components are not limited to only working with String value objects there is no good way for a component to automatically figure out what value object you need. we havent implemented the "do what i mean" functionality yet, but we are working on it :)
[Rosenstrauch, David] 
?   Why couldn't it just do what I'm doing?  i.e.,
 
public TextField(String id) {
    this(id, new Model());
}
 
public TextField(String id, IModel model) {
...
}
 
DR
 

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================


Reply via email to