-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Johan Compagner
Sent: Friday, January 20, 2006 2:25 PM
To: [email protected]
Subject: Re: [Wicket-user] RE: span tag clarification

First of all what is really the use case of this:

add(new TextFiedl("id"));

IF we did new Model() in the constructor?
Because how would you get the data back from that text field?
Are you going to keep references to that textfield and then ask when a form submits its data?
That doesn't seems to much sense to me.
 
I think you don't find much code for formcomponentst that does this:
new TextField("id", new Model()); because it really doesn't make much sense
you want the data to go to somewhere where you can read it.
[Rosenstrauch, David] 
Hmmm.  Maybe I misunderstood how things should work in Wicket then, because that's how I did it:
 
class WicketTest2Form extends Form {
 
  public WicketTest2Form(String id) {
    super(id);
    add(op1 = new TextField("op1", new Model()));
    add(op2 = new TextField("op2", new Model()));
...
    add(result = new Label("result"));
...
  }

  protected void onSubmit() {
    int op1Val = Integer.parseInt(op1.getValue());
    int op2Val = Integer.parseInt(op2.getValue());
    int resultVal = calculator.calculate(op1Val, op2Val, operation);
    result.setModel(new Model(Integer.toString(resultVal)));
  }
 
Maybe I just took the comparisons with Swing a bit too literally.  With Swing:
* you don't have to instantiate a component's model, it gets done for you automatically (although you can change it if you like)
* after the user performs a GUI operation, you query a particular component to get its value, and perform appropriate operations (the component will delegate the value query to its model, but you don't generally call the model directly)
 
 
And you are right easy things easy. And that is just the way it works now
almost all larger apps use CompoundModels because that is so easy to use and not so verbose.
just give a form a compound model and then all the form components can just be created without a model.
How would you do it in this case if we did new Model()?
Then it would suddenly be much harder to do or much mor verbose again.

johan
[Rosenstrauch, David] 
OK.  I'm basically just kicking the tires using a proof-of-concept app right now, trying to learn Wicket's basics.  Maybe I just need to spend more time using and learning about Wicket on some production code and this will become clearer to me.
 
Thanks,
 
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