public class BrandForm extends Form { private Brand brand; private String message; private ModalWindow win; public BrandForm(String id, Brand brand,final ModalWindow win) { super(id); this.brand = brand; this.win = win; add(new Label("created",new PropertyModel(brand,"created"))); add(new Label("updated",new PropertyModel(brand,"updated"))); add(new TextField("name",new PropertyModel(brand,"name")).setRequired(true)); add(new Label("message",new PropertyModel(this,"message"))); add(new AjaxSubmitButton("save",this) { @Override protected void onSubmit(AjaxRequestTarget arg0, Form arg1) { win.close(arg0); } }); } }