You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Audley <CA...@urbanfetch.com> on 2000/08/02 00:54:18 UTC

Struts needs a hook before form validation

Let me set up the scenario.  I have a set of JSP based pages which allow a
user to view and
edit details of a delivery order.  Each client account has a set of
reference fields that can be
unique to that account.  For instance, a law firm may need to not the case
number and
attorney for charge back purposes, while a catalog company simply needs to
not the
order number.  To achieve this, the JSP pages render a set of input fields
for reference data
based on properties of an Account bean.  In order for the page to render
correctly, the
account bean *must* be present.  To ease the burden on the server, the
Account beans are
loaded for each request and stored in the request object before forwarding
to the JSP.

If I use form validation, it is possible that an input on the form will be
incorrect and the struts
framework will send the form back for corrections.  However, when rendering
the JSP, the
Account bean is not available, so an exception is thrown.  I can't ignore
the absense of the
Account bean, otherwise the reference field inputs will not be present,
making corrections
impossible and confusing the user.

I believe that it would be generally useful to have a hook in Struts for
Actions before request
processing begins, sort of an analogue to a tags doStartTag method.  That
way, objects 
necessary for JSP rendering can be guaranteed to be present.

Thoughts?

Chris Audley
Urbanfetch.com

Re: Struts needs a hook before form validation

Posted by Vincent Aumont <vi...@vslab.com>.
You can simply inherit from the 'ActionServlet' class and
overload 'processActionInstance' to add whatever controls
your applicationm requires.

-Vincent.

> I believe that it would be generally useful to have a hook in Struts for
> Actions before request
> processing begins, sort of an analogue to a tags doStartTag method.  That
> way, objects
> necessary for JSP rendering can be guaranteed to be present.