Yep. I'd like to stress though, that you can also work with more than one model in a form. You can set a model on a form (e.g. by passing it to super) for convenience. That way, constructs like:

add(new Label("myField"))

will automatically look up 'myField' in the model that was set on the form. However, a construct like this is also valid:

class MyForm extends Form
{
   final IModel model1;
   final IModel model2;

   public MyForm(String id, IModel model1, IModel model2)
   {
      this.model1 = model1;
      this.model2 = model2;
add(new TextField("field1", new PropertyModel(model1, "myFirstField"))); add(new TextField("field2", new PropertyModel(model2, "otherFieldOnOtherModel")));
   }

   public void onSubmit()
   {
      Customer c = (Customer)model1.getObject(this);
      Other o = (Other)model2.getObject(this);
   }
}

and so on...

So, while form components (and a lot of components like Label etc) make use of their models directly, this is not true for all components. Forms do not use their models directly (same for Page, Panel, Border, etc), and thus you can use as many models as you like.

Eelco


frank bengtsson wrote:

This is nice, does this means that both models are automatically updated  ?

So "onsubmit" all i have do is something like this ?
customerDAO.saveOrUpdate(((Map) getModelObject()).get("customer"));

Thanx in advance !

/Frank




-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to