struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nadia Kunkov" <>
Subject RE: Validate some forms and not the others. How?
Date Mon, 04 Oct 2004 16:30:40 GMT
Thank you.  I think that will work for me.  I have one mapping and I'll just call validate
from the action.
Thanks again

-----Original Message-----
From: Niall Pemberton []
Sent: Monday, October 04, 2004 12:33 PM
To: Struts Users Mailing List
Subject: Re: Validate some forms and not the others. How?

Firstly, if you have separate "mappings" in your struts-config.xml (which
use the same DispatchAction) why can't you set validate to "true" for some
and "false" for others?

Having said that, if you have just one mapping, you could set the
validate="false" in the struts-config.xml and call the form validation, as
required, in your Action's methods...say you wanted validation in an "edit"

public ActionForward edit(
               ActionMapping mapping,
               ActionForm form,
               HttpServletRequest request,
               HttpServletResponse response)
                       throws Exception {

    ActionMessages errors = form.validate(mapping, request);
    if (errors != null && errors.size() >0) {
        return mapping.getInputForward();

    // do the rest of my stuff here


I guess the other alternative would be to put some logic in the ActionForm's
validate method - but that would be kind of duplicating the decision logic
in the DispatchAction


----- Original Message ----- 
From: "Nadia Kunkov" <>
To: "Struts help (E-mail)" <>
Sent: Monday, October 04, 2004 5:10 PM
Subject: Validate some forms and not the others. How?

I'm building an application using DispatchAction.  I have several screens
that use the same ActionForm and I set validate to "true" for this action
The first page of my app is just a jsp with a single button ( I have to
start somewhere :) .  When I click the button on this first page which is
not the form and has no input fields, I guess Struts tries to validate it.
What I see in the log is that I do get into the validate method, the
validation fails and the action itself is not performed.  How can I tell
struts to not validate this first page but validate other screens where
there are input fields.  Since I use dispatch action I can't specify
validate "false" for some actions and "true" for the others, it's just one
That brings me to the next question.  Should I use DispatchAction?
Thanks for your help.

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

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

View raw message