You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Janice <ja...@shaw.ca> on 2003/11/18 02:04:21 UTC

validation occuring before form is loaded, why?

Hi Gang,

I was having problems getting validation to work at all.  I've read every post on getting it to work, followed all step-by-steps, and nothing would ever do it.  Today I yanked all the .jar files out of my lib directory and updated it with the .jar files from the latest release version of struts (1.1).  Well... something started to happen all right, just not what I expected.

What it looks like its doing is validating my form before its even loaded (execute() does not get called, and my print statements in validate() show that super.validate() is returning errors.)

What my code is trying to do is:
1) a list of widgets are displayed.  Each widget has a link to an edit page.  There is also an add widget option.  Both the edit and the add call the same action with a request parameter like addEdit=add or addEdit=edit.

Currently, when either of these links are clicked, I get a 'page cannot be displayed' and my log tells me that there was a validation error.  I don't know why validate() is being called in the first place, I have no explicit calls to it, and didn't expect it to get run until the next form was submitted and my struts-config.xml said validate=true.

2) the next step should be that the action builds the form object with either the reset() values for an add, or a database-retrieved set of values for an edit.  Ideally, when this form is submitted, the form should be validated.  If I change my validate() method on my form object to return a new ActionErrors(), then things work better, but still don't validate.  

I hope this is enough information.  I can post a bunch of code if its not.  I really appreciate any and all help, this validation stuff is taking soooo long to get working!

Thanks in advance,
Janice


Re: validation occuring before form is loaded, why?

Posted by Susan Bradeen <Su...@softlanding.com>.
On 11/17/2003 08:04:21 PM Janice wrote:

> Hi Gang,
>
> I was having problems getting validation to work at all.  I've read every
post
> on getting it to work, followed all step-by-steps, and nothing would ever
do
> it.  Today I yanked all the .jar files out of my lib directory and
updated it
> with the .jar files from the latest release version of struts (1.1).
Well...
> something started to happen all right, just not what I expected.
>
> What it looks like its doing is validating my form before its even loaded

> (execute() does not get called, and my print statements in validate()
show that
> super.validate() is returning errors.)
>
> What my code is trying to do is:
> 1) a list of widgets are displayed.  Each widget has a link to an edit
page.
> There is also an add widget option.  Both the edit and the add call the
same
> action with a request parameter like addEdit=add or addEdit=edit.
>

Just keeping it simple,  you've got something like this?

displayWigetsAction (mapping validate=false) --> displayWigets.jsp
user clicks add button or edit link -->
setupAddEditAction (mapping validate=false)  --> addEdit.jsp
user submits form -->
saveAddEditAction (mapping validate=true)

Susan

> Currently, when either of these links are clicked, I get a 'page cannot
be
> displayed' and my log tells me that there was a validation error.  I
don't know
> why validate() is being called in the first place, I have no explicit
calls to
> it, and didn't expect it to get run until the next form was submitted and
my
> struts-config.xml said validate=true.
>
> 2) the next step should be that the action builds the form object with
either
> the reset() values for an add, or a database-retrieved set of values for
an
> edit.  Ideally, when this form is submitted, the form should be
validated.  If
> I change my validate() method on my form object to return a new
ActionErrors(),
> then things work better, but still don't validate.
>
> I hope this is enough information.  I can post a bunch of code if its
not.  I
> really appreciate any and all help, this validation stuff is taking soooo
long
> to get working!
>
> Thanks in advance,
> Janice
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org