[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    ActionForm and isCancelled...
From:       "Steven D. Wilkinson" <stevendwilkinson () acm ! org>
Date:       2000-12-31 23:46:27
[Download RAW message or body]

I had a issue with a form and the cancel button.
I'm using the cancel button from the submit tag library in my jsp:
<form:submit property="cancel">
    <bean:message key="button.cancel"/>
</form:submit>

When I display the Form and the user wants to Cancel I have to look for the
cancel button parameter using the same technique as the
isCancelled(HttpServletRequest request) method within the Action class.  Is this
common enough that some could add an isCancelled(HttpServletRequest request)
within the ActionForm class?

My dilemma is that I don't want to perform any validation if the user presses
the cancel button.  Here is what I did to my ActionForm class.

...
import org.apache.struts.taglib.form.Constants;
...

   public ActionErrors validate(ActionMapping mapping,
           HttpServletRequest request) {
      ActionErrors errors = new ActionErrors();
      if(isCancelled(request)) {
         return errors;
      }
      ....
   }

    protected boolean isCancelled(HttpServletRequest request) {
      return (request.getParameter(Constants.CANCEL_PROPERTY) != null);
    }

This would eliminate duplicate code in ActionForm classes.  I know I could
extend the ActionForm and use that, but I think this is something that a lot of
people could use.  Just my opinion though.

What does everyone else think?

Thanks in advance,
Steve

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic