Raible's Wiki

Raible Designs
Wiki Home
Recent Changes


  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in

Referenced by

JSPWiki v2.2.33


Hide Menu


Difference between current version and current version:

At line 1 added 81 lines.
!!__2003.10.30__ - Thank you for struts-resume
Hi Matt,
Kudos on your excellent work on appfuse and struts-resume. Since, I've been using appfuse and struts-resume to gather a basic understanding of struts and "helper" technologies, its time to give back a little.
I ran into the same problem as yourself, as per [your email|http://www.mail-archive.com/struts-user@jakarta.apache.org/msg60169.html]. So, I followed the email thread and wasn't quite happy with the JavaScript solution. So, I conjured a non-JavaScript solution which is posted below. Be aware that my struts understanding is fairly rudimentary and this might be a classic example of too much blending of V into the C from the MVC model.
This is part of action.BaseForm
* An overridden validate method which attempts to bypass
* validation.
* <div id="caution_overridden_validate" title="Overridden Validate">
* Due to a bug (or unintended feature) in struts, as
* explained in
* <a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16401">this bu
g report</a>
* its difficult (or impossible) when using the Validator with
* LookupDispatchAction to bypass validation on a method level
* without employing JavaScript. I thought it would be nice to have
* a cancel method with no dependency on JavaScript which was able
* to bypass validation. Hence, in this class we override the
* validate method and look for the parameter name (e.g., action) and
* its value (e.g., Cancel) and if the cancel button was pressed,
* the call to super.validate is bypassed.
* <a href="http://www.mail-archive.com/struts-user@jakarta.apache.org/msg60
169.html">Initial report</a>
* by Matt Raible on struts-user mailing list.
* Follow up
* <a href="http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg129
* and
* <a href="http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg129
* by Brandon Goodin on struts-dev mailing list.
* </div>
* @param mapping The <code>ActionMapping</code> used to select this
* instance
* @param request The servlet request we are processing
* @return <code>ActionErrors</code> object that encapsulates any
* validation errors
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// Identify the request parameter containing the method name
String parameter = mapping.getParameter();
if( parameter != null ) {
// Identify the method name to be dispatched to.
String name = request.getParameter(parameter);
MessageResources resources =
(MessageResources) request.getAttribute(Globals.MESSAGES_KEY);
// Identify the localized message for the cancel button
String message = resources.getMessage("button.cancel");
// if message resource matches the cancel button then no
// need to validate
if( name != null && name.equals(message) ) {
if( log.isDebugEnabled() ) {
log.debug(mapping.getAttribute() + " '" + name +
"' method, so no need to validate");
return null;
// perform regular validation
return super.validate(mapping, request);
What do you think of this approach?
Haroon Rafique haroon.rafique@ca.utoronto (reverse the domain to send email)
;:''This looks good Haroon - thanks for the code sample. ~ [MattRaible]''

Back to ValidatorDispatchAction, or to the Page History.