You were right. Once I declared the error header and footer and rechecked
the name value pairs for my errors, everything works great. Multiple errors
are displayed and the re-populate works as well. This is great stuff!
Erich Kilmer
Bell+Howell

-----Original Message-----
From: Ted Husted [mailto:[email protected]]
Sent: Tuesday, September 18, 2001 7:09 PM
To: [EMAIL PROTECTED]
Subject: Re: ActionError display and re-populate problem


"Kilmer, Erich" wrote:
> I am working on a Struts prototype. I have the basic flow going between a
> couple of pages. What I am trying to get working now is the ActionError
> part. In my ActionForm I am detecting errors, creating ActionError and
> sticking them in ActionErrors which is returned from the validate method.
> 
> In my input JSP, I have tried both the <html:errors/> and the
> <struts:errors/> tags. But this is what is happening. First even if there
> are multiple errors only a single one is being displayed, usually it is
the
> first error.
> 
> Second, shouldn't the input text fields be re-populated? They are always
> blank. I saw an example in the Action class's perfrom method where errors
> are stored in the request. Is this necessary in the ActionForm's validate
> method too?

The input text fields should be repopulated (that's pretty much the
whole idea ;-), and all your errors should be displayed if you are using
the standard <html:errors/> tag. Just be sure the standard tokens are
defined in your application resources file, such as

errors.header=<ul>
errors.footer=</ul><hr>

In this case, your errors would be wrapped in <li>..</li> codes in your
application resources. 

sql.access.error=<li>Unable to access database. Please try again
later.</li>
sql.access.empty=<li>Requested records were not found.</li>

Validate returns to the controller, which saves the ActionErrors to the
request for you (when it is not null), and then returns control to the
URI indicated by the input property. 

Is your original data-entry page and the input page on the Action
mapping it submits to the same page? 


> Last question, there <html:form>, <struts:form> and <form:form> which one
to
> use?

<html:form>

The others are deprecated. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/

Reply via email to