At 2:07 PM -0400 2002/10/23, Seth Milder wrote:
>I am designing a webapp using Struts and I would like to include
>with every ActionForm class an inner servlet class that queries a DB
>to get config info for the outer class. I would then use this
>information in the validate() routine to determine which fields
>should be validated and which should not be (it will basically be a
>list of required fields for a given webapp). The trouble is that
>when I try to call the servlet I get a stack trace (see below). Is
>there a better way of doing this with Struts? Is a servlet in an
>inner class impossible?
whoa -- that's twisted! I don't know if the Servlet spec supports
inner classes as servlets, but the design intentions of Struts are
for the ActionForm classes to be relatively stupid objects used to
push data around.
Why not just have your Action class do the database stuff? There's
no strict reason why you need to validate action forms with the
validate() method; it's just a convenience.
If you want your actions to be able to deal with multiple forms for
some reason, you could write a Struts PlugIn that puts itself into
the ServletContext at initialization time, and then is available to
all of your actions to validate the ActionForms.
Is there a strong reason to have the validation rules in a database
instead of in an XML file? Have you checked out the Validator system?
There's got to be a less tangled way to achieve your ends...
Joe
--
--
* Joe Germuska { joe@germuska.com }
"It's pitiful, sometimes, if they've got it bad. Their eyes get
glazed, they go white, their hands tremble.... As I watch them I
often feel that a dope peddler is a gentleman compared with the man
who sells records."
--Sam Goody, 1956
--
To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
|