Greg Akins
2010-12-09 18:46:10 UTC
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?
(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?
--
Greg Akins
http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre
Greg Akins
http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre