Hi Greg,
I use in my code @SkipValidation annotation for method which I don't
want to validate. For me it is easier than use interceptors.
@SkipValidation
public String cancel() {
return SUCCESS;
}
The second part - redirect - I hope is correct.
Regards, Michal.
Greg Akins wrote on 9.12.2010 19:46:
I need to have a "Cancel" button on a form that skips the validation
(Struts 2.2.1). This seems harder than it should be and maybe I'm
missing something.
I've read a few posts about this and ended using the validation
interceptorref to get this to work.
I've had problems getting the interceptorref mechanism to work
@Action(value = "hello-world-cancel",
interceptorRefs = { @InterceptorRef(value =
"validation", params = {
"excludeMethods", "cancel" })},
results = { @Result(name = SUCCESS,
location="/jsp/logon.jsp") })
public String cancel() throws Exception {
LOG.debug("Cancelled", "The form has been cancelled");
return SUCCESS;
}
The problem is.. I've got this working as part of the Maven
struts-archetype-starter application. However, I can't manage to get
the same thing working on my application
Bother are using theme="xhtml".. but my application will only do the
Error Messages and labels if the validate="true" is set on the form.
However, setting the validate=true on the form forces client-side
javascript to be built which is run everytime the form is submitted,
even if it's submitted from the cancel button.
The HelloWorld application looks like it's using serverside validation
(since there isn't any javascript in the page.. but the error messages
and labels still appear).
Any thoughts on what I might be missing?