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've been called that before :)

 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.
Maybe you are right. I am new to all of this, so my ideas may not be very good.

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.
Intersting. Can you give me a link? Or an example? Sorry if I seem obtuse.

Is there a strong reason to have the validation rules in a database
instead of in an XML file?
No. But I want them to be configurable at runtime. I suppose I could do that in an XML file, but databases are more natural for me personally.

  Have you checked out the Validator system?
No. What is that?

There's got to be a less tangled way to achieve your ends...

Joe

I hope so. Thanks for the speedy reply. I knew this list would set me straight :)

--
Seth Milder
Department of Physics and Astronomy
MS 3f3
George Mason University
Fairfax, VA
http://www.mrseth.org
--
Most people prefer certainty to truth.


--
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