I have a simple, cryptic problem with a label and using ajax to display it.
public class ChecklistTemplateForm extends Form{
private static final long serialVersionUID = 1L;
private Label cantSaveLabel;
public ChecklistTemplateForm(String id) {
super(id);
cantSaveLabel = new Label("cantSaveLabel", "Name is not unique, enter another name and try saving again.");
cantSaveLabel.setVisible(false);
cantSaveLabel.setOutputMarkupId(true);
add(cantSaveLabel);
add(new AjaxButton("saveButton") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
target.addComponent(cantSaveLabel);
if (canSave){
setResponsePage(AdminCheckListPage.class);
}
else if (!canSave){
cantSaveLabel.setVisible(true);
System.out.println(canSave);
}
}
});
}
}
The funny thing is that canSave is false, System.out.print works, but cansavelabel never becomes visible. What am I missing?
source
share