Thanks for the response.  I think I found the solution I was looking
for... after browsing through the define taglib sources:

Use define:bean, as in:

<define:taglib uri="myplugin">
    <define:tag name="dependency-handle"/>
    <define:bean name="mytag" className="com.foo.MyTag"/>
    <define:bean name="myparenttag" className="com.foo.MyParentTag"/>
</define:taglib>

Then override MyTag's findAncestorWithClass() as:

<snip>
protected Tag findAncestorWithClass(Class type) {
    // First try the default
    Tag tag = super.findAncestorWithClass(type);
    
    if (tag == null) {
        // Then try looking for a DynamicBeanTag
        tag = findDynamicBeanAncestorWithClass(getParent(), type);
    }
    
    return tag;
}

protected Tag findDynamicBeanAncestorWithClass(Tag parent, Class type) {
    if (parent == null) {
        return null;
    }
    
    if (parent instanceof DynamicBeanTag) {
        DynamicBeanTag tag = (DynamicBeanTag)parent;
        Object bean = tag.getBean();
        if (type.isAssignableFrom(type)) {
            return (Tag)bean;
        }
    }
    
    return findDynamicBeanAncestorWithClass(parent.getParent(), type);
}
</snip>

This will unwrap the DynamicBeanTag and allow MyTag to behave as
excepted when looking for an ancestor tag.

With this combination, I can from an external project do something like:

<project xmlns:myplugin="myplugin">
    <myplugin:myparenttag>
        <!-- can talk to myparenttag via findAncestorWithClass() -->
        <myplugin:mytag/>
    </myplugin:myparenttag>
</project>

Cheers,

--jason



===========================================================================
This email and any attachment(s) thereto, are intended for the use of
the addressee(s) name herein and may contain legally privileged and or
confidential information under applicable law. If you are not the 
intended recipient of this e-mail, you are hereby notified any 
dissemination, distribution or copying of this email, and any attachment(s)
thereto, is strictly prohibited. If you have received this communication
in error, please notify the sender at 415-281-2200 or via return e-mail at
[EMAIL PROTECTED] and permanently delete the original copy and 
any copy of any e-mail, and any printout thereof. Thank you for your 
cooperation.





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

Reply via email to