Hi, I'm trying to figure out how to expose a Java TagLibrary from a
plugin. Inside of my plugin, I can create a: <define:taglib uri="myplugin"> <define:tag name="dependency-handle"> </define:tag> </define:taglib> And I can access this taglib just fine from another project. Similarly in my plugin, I can define: <project xmlns:local="jelly:com.whatever.jelly.MyTagLibrary"> <local:sometag/> </project> And I can now access the Java TagLibrary MyTagLibrary from inside the plugin. But, what I am trying to do is to create a plugin which provides a set of tags for use in other projects. How can I expose a Java TagLibrary as if it were a <define:taglib> inside of my plugin.jelly? I tried using <define:jellybean>, <define:bean> with no luck. While I was able to get the tag to attach to the taglib, it did not allow the tags to properly find their parent via findAncestorWithClass(). So far the only luck I have had with exposing Java TagLibraries externally is to have the plugin nest the tags inside of a dynamic tag created. Is this even possible with Maven 1.0.2? If so, could someone explain how I can do this. Thanks, --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 [hidden email] 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: [hidden email] For additional commands, e-mail: [hidden email] |
There are a couple of alternatives.
Like the artifact plugin, you can wrap the java in a "jellybean", and use the exported tag library for that. I think this is what you describe below as unsatisfactory. The other alternative is to put the tag library in a JAR, add that as a dependency on the project, and reference it like this: xmlns:foo="jelly:com.foo.tags.FooTagLibrary" See the Xdoc plugin for an example where it references it's own classes to do that. HTH, Brett On 6/7/05, Jason Dillon <[hidden email]> wrote: > Hi, I'm trying to figure out how to expose a Java TagLibrary from a > plugin. > > Inside of my plugin, I can create a: > > <define:taglib uri="myplugin"> > <define:tag name="dependency-handle"> > </define:tag> > </define:taglib> > > And I can access this taglib just fine from another project. > > Similarly in my plugin, I can define: > > <project xmlns:local="jelly:com.whatever.jelly.MyTagLibrary"> > <local:sometag/> > </project> > > And I can now access the Java TagLibrary MyTagLibrary from inside the > plugin. > > But, what I am trying to do is to create a plugin which provides a set > of tags for use in other projects. > > How can I expose a Java TagLibrary as if it were a <define:taglib> > inside of my plugin.jelly? > > I tried using <define:jellybean>, <define:bean> with no luck. While I > was able to get the tag to attach to the taglib, it did not allow the > tags to properly find their parent via findAncestorWithClass(). > > So far the only luck I have had with exposing Java TagLibraries > externally is to have the plugin nest the tags inside of a dynamic tag > created. > > Is this even possible with Maven 1.0.2? If so, could someone explain > how I can do this. > > Thanks, > > --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 > [hidden email] 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: [hidden email] > For additional commands, e-mail: [hidden email] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
In reply to this post by Jason Dillon-5
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 [hidden email] 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: [hidden email] For additional commands, e-mail: [hidden email] |
Free forum by Nabble | Edit this page |