Here's a snippet of one of the jsp files.

I'd almost forgotten myself that I added the getAttribute("sessionForm")
some time ago.
I'm working on an application that uses several jsp pages to gather one set
of information before it really does anything with it. Ideally, the first
form gets validated before the user can get to the second form and that must
be validated before the third .... And of course all of this must work if
the user hits the browser's navigation buttons.

Before I added any validation at all, I found that when I filled out one
page and went on to the next page, I'd lose whatever was added in the first
page unless I put the sessionForm as an attribute. Simply specifying that
the form was in session scope didn't keep the information around. In my
research, this was something that some people did and others didn't. I
wasn't clear on when or why.

So maybe the use of the Javascript to fill input values is killing something
that struts is trying to do. I just know that without this, I didn't keep
information between requests.

The reason for overriding the validate method was to set the sessionForm
attribute. I was also just starting to try to use the ValidateForm.setPage().
As I understand it, that field (page) should enable me to have validation
done only on parts of the form. I haven't seen any examples and am just
trying it out as we speak.

 <% AllDonationInformationFormBean3 sessionForm =
(AllDonationInformationFormBean3)request.getAttribute("sessionForm") ;
    if(sessionForm == null) sessionForm = new
AllDonationInformationFormBean3() ; %>
 <body>
   <center>
     <h1>New Account Registration</h1>
   </center>
   <form action="../donation3/donation3.do" method="post">
     <input type="hidden" name="pagename" value="donationPage"/>
     <p style="background-color:rgb(0,255,255); font-size:large;">Donor
Information</p>
     <html:errors/><br/>
     <p>*Indicates required field</p>
     <p>
       Title
       <select name="salutation"/>
          <option value="Mr.">Mr</option>
          <option value="Ms.">Ms</option>
       </select>
     </p>
     <P>
       <font color="red">*First Name: </font>
       <input type="text" name="firstname" value="<%=
sessionForm.getFirstname() %>" /><br/>

       <font color="red">*Last Name:        </font>
       <input type="text" name="last"  value="<%= sessionForm.getLast()
%>" /><br/>



On 11/7/06, Christopher Schultz <[EMAIL PROTECTED]> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thom,

Thom Burnett wrote:
> With that fixed I can take out the sub class' validate() method and
still
> get a set of errors.

That's good, I guess. What do you mean, the subclass's validate method?
I didn't realize that you had multiple levels of validation being
performed.

> However, getting errors still depopulate's the form's fields.

That shouldn't happen. Lemmie look at your JSP source again...

Ah. You didn't provide any of the HTML code that contains the <input>
elements. Could you post a representative sample?

> Again, I can
> fix that by overriding the validate method (calling super) and that's
not a
> horrible solution

Yeah... don't do that. You should be able to work directly with the bean
that you already have. No need to go through any acrobatics like this.

Just so I know, what is the superclass for this bean and what does its
super.validate method do that you aren't doing in the subclass?

Come to think of it, why are you overriding the superclass's validate
method in the first place? And... if you are overriding it, why aren't
you calling that superclass method first thing in your overidden method
implementation?

If you have a "base form bean" that contains some utility methods, you
should not have to call super.validate(). On the other hand, if you have
a super class bean that needs its validation done /too/, then you should
do this:

public ActionErrors validate(...)
{
   ActionErrors errors = super.validate(...);

   // Now perform your own validation.

   return errors;
}

> As near as I can see the form is being named and associated correctly
but I
> must be missing something.

It looks like validate() is being called, otherwise you wouldn't be
getting error messages. Since your action mapping names the bean /and/
the input attribute is associated with the mapping (i.e. there's no
redirect), that bean (including its invalid input) ought to be available
in the session (as per your 'scope' preference).

Post your JSP code around your <input> elements and let me have a look.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFUM8a9CaO5/Lv0PARAsyxAJ9YtgRv+A4MQgUi5n4zppJVkTcFIQCfeM3n
yrmuTXI0ttkeoceXAFyr/aQ=
=wyhj
-----END PGP SIGNATURE-----

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


Reply via email to