public AddTodoForm(String id)
{
super(id, new CompoundPropertyModel<TodoItem>(new TodoItem()));
setOutputMarkupId(true);
add(new TextField<String>("text"));
add(new AjaxButton("add", this)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
// retrieve the todo item
TodoItem item = (TodoItem)getParent().getDefaultModelObject();
// add the item
onAdd(item, target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form)
{
}
});
add(new AjaxButton("cancel", this)
{
@Override
public void onSubmit(AjaxRequestTarget target, Form<?> form)
{
onCancelTodo(target);