Hi there,
   I just went through this exact same issue.  What I ended up doing, is in the 
struts-config file I changed the validation to "false" and then called the 
ActionForm.validate() method from my Action class.  If the ActionErrors returned from 
that method is not empty, then I had to get my collection from the database again and 
put it back in the request, and then forward back to my input page.  The code segment 
from my Action class looks like this:

         ActionErrors ae = userform.validate( mapping, request );
         // If the form validation fails it will return a non empty ActionErrors object
         if ( !ae.empty() ){
            saveErrors( request, ae );
            Collection pageProfs = uda.getProfiles();
            request.setAttribute( Keys.PROFILES, pageProfs );
            log.trace( "mapping.getInput() returns: " + mapping.getInput() );
            return( new ActionForward( mapping.getInput() ) );
         }

This should work for you.

Brian

>>> [EMAIL PROTECTED] 01/23/02 03:40pm >>>
If we have a proper ActionForm with the same field as our <html:form>,
validation error retrieves the user entered values.

But if we have a List/Collection of data saved as a property of the
ActionForm 
OR as request attribute,
How to retrieve this data, when there is a validation error. 
For Example:
I have a list retrieved from database and saved as request attribute 
(I don't want to use more data in session) 
to display as multiple radio buttons on one JSP as part of <logic:iterate>. 
I validate the ActionForm when the user tries to go to next page.
When I get validation error, the collection <logic:iterate> gets is NULL. 


-----Original Message-----
From: David Gaulin [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 24, 2002 4:09 AM
To: Struts Users Mailing List
Subject: Re: Question about forms and validation.


Mike,

If you have the proper ActionForm class which represent the proper field in
you form and you use the struts html custom tag, your data should come back.
That is one of the best feature of Struts.

Hope this helps

David

----- Original Message -----
From: "Witt, Mike (OH35)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 23, 2002 2:56 PM
Subject: Question about forms and validation.


> Hi,
>
> I have a question about the validate method on the ActionForm.  From my
> understanding,
> if a validation error is found, you set up a collection of ActionErrors
and
> return this.  This
> causes struts to forward back to your input form, correct?
>
> In my situation, I populate a form for editing.  When the submit is
clicked,
> I validate the entry.
> When a validation error occurs, it always displays the original form data.
> Is there a way to
> get it to display the form as the user edited it?  Many times a large
> quantity of good data is
> lost because of one bad field.
>
> Thanks for your help,
>
> Mike Witt
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to