public Task {
private int id;
private Company sender;
private Company receiver;
//Getter and Setter
...
}
As you can see, I have 2 other custom classes in the task class. And a company has for example Adress and Directory (see screenshot below).
You could create a CompanyPanel
which takes a IModel<Company>
. You could use a PropertyModel on your task class to get one. PropertyModel sender = new PropertyModel(myTask, "sender")
. The panel then can have two TextFields for which you can use a CompoundPropertyModel on the IModel that is passed.
Reuse this panel twice on your form.
On the CompanyPanel
public class CompanyPanel extends Panel
{
public CompanyPanel(String id, IModel<Company> model)
{
super(id, new CompoundPropertyModel(model));
add( new TextField("address"));
add( new TextField("directory"));
}
}
Lookup the CompoundPropertyModel in the docs. It is really useful.