Perhaps I'm misunderstanding the problem, but if there are two ActionForms 
for the page, then there are presumably two HTML forms on the page. When 
you submit one of those forms, you submit just that - one form. Therefore, 
the contents of the second form on the page won't get submitted, and can't 
be validated on that request.

Given this, the problem reduces to having the errors generated from the one 
form that was validated show up alongside that form when the page is 
redisplayed, instead of having all errors show up in the same one place on 
the page. One solution to this would be to have two occurrences of 
<struts:errors/> on the page, once for each form, but wrapped with logic 
tags so that only one of them will actually be invoked. For example:

<logic:equal name="whichForm" value="form1">
   <struts:errors/>
</logic:equal>

where you would set whichForm in your Action to specify which form you want 
to display the errors for. Would this fit your needs?

--
Martin Cooper
Tumbleweed Communications


At 11:26 AM 1/11/01 -0800, John Hunt wrote:
> > Your validation method would then queue up whatever
> > error messages
> > should be communicated to the user, and display them
> > all on your input
> > form. (ActionErrors is a collection.)
>
>As I said if there are two ActionForms in a html page
>and thus two action classes to handle. So depending on
>the request the corresponding action class is executed
>and if it returns an ActionError, all <struts:errors>
>does is display the error message. But I want it like
>if the ActionError has been generated by Action1 class
>display it in section 1 of the html page and if it is
>2 then in second section. Does this mean that I can
>have <struts:errors> at two places??? Which I dont
>think so because it would display the message twice.
>-- How in a JSP file I can distinguish between errors
>returned by different Action classes - is my question?


Reply via email to