So I started with inheriting Form Bean configuration.  It seemed like
the best candidate because it's where the feature seemed most
applicable at first glance.  Once I had that working, I moved on to
ForwardConfig.

I figured, it should be easier and more straightforward.  No
subelements like a form bean's form properties, and I already know the
basic approach from working on Form Beans.  Well ForwardConfig didn't
want to cooperate by making it easy for me since I had to deal with
global forwards and action forwards.  I especially liked this:

<global-forwards>
    <forward name="success" path="/home.jsp"/>
</global-forwards>

<action-mappings>
    <action path="/somePath"
        type="SomeAction">
        <forward name="success" extends="success" redirect="true"/>
    </action>
</action-mappings>

 ... where I interpret /somePath's <forward> as <forward>whatever's in
the "success" global-forward, but with a redirect</forward>.  Form
Bean config inheritance worked by finding config objects by name. 
With ForwardConfig, the ancestor's name could be the same, so we do
some hacking^H^H^H^H^H^H^H tweaking.

Now we move to ActionConfig.  Should be simple, right?  Action
mappings are already global within the module.  Sure there are
subelements, but we should be able to apply what we learned from
FormBeanConfig.  Ha ha, not so fast.  I started inheriting the
forwards from another action mapping, then came across this scenario:

<action path="/somePathA"
        type="SomeAction"
        name="someForm">
    <forward name="baseForward" path="/page1.jsp"/>
    <forward name="subForward" extends="baseForward" redirect="true"/>
</action>

<action path="/someOtherPath"
        extends="/somePathA">
    <forward name="subForward" module="/otherModule"/>
</action>

What does /someOtherPath's subForward look like?  After some thought,
I had the answer: redirect to /otherModule/page1.jsp

We "inherit" the forward definition of the same name from the action,
which by that time, should be expanded already.  For cases like this,
the "extends" tag is also inherited, although in the case above, there
was nothing more to inherit.


Once you get started with weird cases, of course, you won't be able to stop:

<action path="/somePath"
        type="SomeAction"
        name="someForm">
    <forward name="baseForward" path="/page1.jsp"/>
    <forward name="subForward" extends="baseForward" redirect="true"/>
</action>

<action path="/someOtherPath"
        extends="/somePath">
    <forward name="baseForward" path="/page2.jsp"/>
    <forward name="subForward" module="/otherModule"/>
</action>

What does /someOtherPath's subForward look like now?  Answer: redirect
to /otherModule/page1.jsp.  The "extends" was inherited, but by first
inheriting /somePath's subForward, the "path" property already had a
value, so there was nothing to inherit from /someOtherPath's
baseForward.


<action path="/somePath"
        type="SomeAction"
        name="someForm">
    <forward name="baseForward" path="/page1.jsp"/>
    <forward name="subForward" extends="baseForward" module="/otherModuleA"/>
</action>

<action path="/someOtherPath"
        extends="/somePath">
    <forward name="baseForward" path="/page2.jsp"
module="/otherModuleB" redirect="true"/>
</action>

What's the value now for /someOtherPath's subForward?  Answer:
redirect to /otherModuleA/page1.jsp


==============


Here's what I have so far.  There are still debug statements I'll be
removing, and a bunch of TODO items to update messages.  I'll get to
these before I check in code.
http://www.rabago.net/struts/configinheritance/configinheritance.txt

Here's the config (so far) of the sample app I'm playing with:
http://www.rabago.net/struts/configinheritance/struts-config.xml


Hubert

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to