+1
.V

Joe Germuska wrote:
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




--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to