Michael Delamere wrote:

Eddie,

you said once (if I remeber correctly), that you extended the
struts-config.xml to accommodate your own configuration settings.
Incorrect. I used a seperate XML config and used digester to parse/instantiate things.

I would appreciate it if you took a minute or two in answering my
questions :-) :

Did this involve a lot of overhead?
org.apache.commons.digester - see that package description.  It's *cake*!

Are you having to change the dtd? - which would require you to update
every time you installed a new struts-version.

Nope. ... and that's why I tacked mine on instead of making it core. Remember, I'm "XML- and DTD-stupid (TM)".

Is there an easy way to retrieve the values from you action?

Well, assuming you poke whatever you create into some reasonable scope (application!), and utilizing some reasonable scheme (so different modules don't trample each other), you have access to it wherever you like.

I would be equally happy if you directed me to a good documentation that
might be of some help.

See org.apache.struts.action.PlugIn for how you'll do your initialization. There are several digester examples in the Struts code-base. Look at the PlugIn implementations available in Struts and then if you still have questions I can shoot you a skelleton. In fact, I think I posted one to the list some time back. I've been intending to add an example to the User Guide too - will try to do that sometime soon.

Thanks in advance,

Regards,

Michael

Anytime ;-)

commons-digester is supercalafragilisticexpealedociously cool. If you're looking at adding some custom "thing" to Struts, I highly recommend it. I can't imagine a simpler approach to making your configuration declarative (versus programatic - ack - do you really want to change code to change your config? Not me!) The rules you setup can be a bit difficult to understand at first, but, with some requisite amount of tinkering (doesn't take a lot) you'll figure it out fast. If you do hit problems just yell.

Game Plan:

1 - Conceive an XML representation of the structure you wish to create (structure = composition of objects - ApplicationConfig contains ActionConfig etc).
2 - Generate a set of rules for digester that will do what you want with the structure you've conceived.
3 - Write an implementation of the o.a.s.a.PlugIn interface that will actually load things and put them into scope.
4 - Include your PlugIn implementation in your struts-config.xml
5 - Sit back and radiate pride for having built an add-on component that can be included in each module.

Notes:
- *could* take one config file for the entire application
- *should* (probably) allow one config file per module (using a scheme akin to what Struts does - or something else that guarantees uniqueness)
- There's really no rule here - do what makes sense for *your* application

My approach was to just programatically setup the rules in the PlugIn by calling various digester.addXXX methods (you'll see). You can also use plugable rulesets. For what I'm doing I just didn't see the advantage. My stuff was pretty view-centric (and Struts-centric, at that), so I don't really envision it ever being useful outside of Struts - or a servlet container, for that matter.

If what you're doing is web-centric, but not Struts-centric, you may wish to use a ContextListener instead of a PlugIn implementation. If what you're doing requires some information from the Struts config (as mine did), then you'll most certainly find a PlugIn implementation a cleaner solution.

I did not provide a DTD for my XML config. You may wish to. Digester supports this (though I can't speak to how easy it is to implement - my guess is that part is easy too).

Good Luck! Yell back if you have problems.

--
Eddie Bush





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