I am trying to put a form on a page that can only be submitted if the user is
logged in. If the user is not logged in, I would like them to be able to
submit the form but be redirected to the login page. Then after successful
login, the original form submission is processed.
I am using 1.5.3 currently.
Here is what I was hoping would work but I keep getting the <ajax-response>
sent to the browser instead of the submit continuing.
AjaxButton addButton = new AjaxButton("add") {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
if (!MySession.get().isAuthenticated()) {
throw new RestartResponseAtInterceptPageException(Login.class);
}
MyModel mm = (MyModel) form.getModelObject();
myService.addData(mm, MySession.get().getAccount()); //myService is a
SpringBean
this.setResponsePage(getPage()); // reload the entire page for now
}
};
add(addButton);