struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Multiple buttons and validation
Date Tue, 12 Dec 2006 17:36:12 GMT
Hash: SHA1


Thom Burnett wrote:
> I have a few buttons on my jsp page and I want to have validation happen on
> some buttons and not on other buttons.
> Is that possible? How? Any examples around?

This question came up a few weeks ago, and I'll tell you what I told
whoever asked in the past. There may be other solutions, but this one is
fairly straightforward.

First, you create an action that is intended to handle the form
submission itself. No need for a form bean or anything like that (and,
of course, there's no validation). Just write it like this:

public ActionMapping execute(...)
    if(null != request.getParameter("first_button"))
       return mapping.findForward("first-forward");
    else if(null != request.getParameter("second_button"))
       return mapping.findForward("second-forward");
    else if(null != request.getParameter("third_button"))
       return mapping.findForward("third-forward");

Then, your first-, second-, and third-forwards can be defined to forward
(not redirect) the request to the "real" actions that do whatever you
want them to do. /Those/ actions should have form bean associated with
them and validation="true" in the mappings.

Remember that your "real" actions should all have the same "input" set
so that any validation errors will go back to the same page.

Hope that helps,
- -chris
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message