I'm not exactly sure of your sequence of events, but keep in mind:
- If your form bean has a validate() method, then by default the
ActionServlet will call that validate method. If it returns any error
messages then the ActionServlet forwards to the specified input. This
all happens BEFORE the call to your Action.perform method. So, if the
input page depends on the Action.perform putting certain beans into the
session, it might not happen.
If this is what's happening to you then I'd refactor the code:
- set validate="false" in the action tag,
- in Action.perform set up your session beans
- in Action.perform do your validation
- if there are any errors then forward to the input
Regards, Will
----- Original Message -----
From: "Todd Story" <[EMAIL PROTECTED]>
To: "Struts-User (E-mail)" <[EMAIL PROTECTED]>
Sent: Thursday, May 31, 2001 9:01 AM
Subject: New user: ActionForms, request attributes and validation
> When I have a validation send back errors, and I have previously set
Request
> attributes in my subclassed Action, when the control gets sent back to
my
> input page, my Form is still in the request, but it looks like my
other
> attributes that are set (namely lookup type lists) are not in this
list.
>
> I'm setting up lookup lists in the Action and setting the attribute
via
> "request.setAttribute(....)" and this all works wonderfully up until
the
> point mentioned above. I get an ServletException that says the
following
> "javax.servlet.ServletException: Cannot find bean under name
segmentNames".
> segmentNames is the request attribute.
>
> Any help in design or whatever would be appreciated. I noticed how
one user
> put the lists in the servlet's context, but I see some obvious
scalability
> problems there. Also, all of the samples are building these lists via
jsp
> scriptlets, which I thought was what you wanted to avoid by using
struts.
>
> Thanks.
>