You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthias Gries <Ma...@oracle.com> on 2001/09/10 13:51:59 UTC

Some questions regarding data validation!

Hi all,

since I'm relatively new to struts the following questions could seem a
little bit silly ;-)
But I haven't found any information on the mailing lists right now. So
it would be really helpful if someone could answer them.

1) Is there any reason why the scope for ActionErrors is the request and
not the session?
2) Our web application generates the gui via html frames. The upper
frame displays a data entry form, the lower frame displays either a
result page or a new form or an error page. If I enter some data into
the data entry form and I hit the submit button the lower frame will be
populated (target = "lowerFrame"). Now here is my problem: When I
validate the inserted data I only can display possible errors in the
lower frame (because the submit aims to the lower frame) via
<html:errors/>. But in our case we want to display some error messages
right above the input field which has caused the error (like "Wrong date
format"). But because the errors are within the scope of the request and
not of the session I have no possibility to display them in the upper
frame. How can I manage to display error messages within the upper frame
after submitting the data and then eventually populate the lower frame?
Any help and idea will be appreciated!!!

Thanks a lot
Matthias



Re: Some questions regarding data validation!

Posted by Ted Husted <hu...@apache.org>.
Matthias Gries wrote:
> 1) Is there any reason why the scope for ActionErrors is the request and
> not the session?

If the errors are kept in the session, you could, theoretically, end up
exposing messages that related to another request, which would be
confusing ;-) As a request object, it is disposed when the request is
complete, so we don't have to worry about tracking which errors were
communicated to the user and which were not.

> 2) Our web application generates the gui via html frames. The upper
> frame displays a data entry form, the lower frame displays either a
> result page or a new form or an error page. If I enter some data into
> the data entry form and I hit the submit button the lower frame will be
> populated (target = "lowerFrame"). Now here is my problem: When I
> validate the inserted data I only can display possible errors in the
> lower frame (because the submit aims to the lower frame) via
> <html:errors/>. But in our case we want to display some error messages
> right above the input field which has caused the error (like "Wrong date
> format"). But because the errors are within the scope of the request and
> not of the session I have no possibility to display them in the upper
> frame. How can I manage to display error messages within the upper frame
> after submitting the data and then eventually populate the lower frame?
> Any help and idea will be appreciated!!!

You could use your own SaveErrors routine to put them into the session
instead, and edit html:errors to look there instead. (You could put this
copy into your own taglib library, and reference that instead.) You
would also need a way to clear the errors afterwards, or at least before
another use of the session object. 

This approach could cause problems if they had more than one window open
that used the same session, but you might not care about that ;-) Or, it
might be possible to do something clever with request tokens to get
around that. Pick your poison, I guess.

The best place to post questions like this is the USER list. Please do
not cross-post to DEV.

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