Re: Allow multiple taglib.xml files for the same namespace

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Fri, 13 Nov 2009 08:14:53 -0800

Thanks for the analysis and patch Matthias.

Would you mind opening an issue for this and we can move on from there?

On 11/13/09 7:01 AM, Matthias Berndt wrote:
> Hello,
> first I'd like to explain my intention. The scenario is writing multiple
> JSF components being bundled in more than one java archive. Each java
> archive has its own taglib.xml descriptor so you can use them
> separately. These components belong to the same project or organisation
> and should be published within the same namespace. This isn't possible
> with facelets at the moment and is a known issue to facelets. See:
> To support this scenario I'm aware of 3 possible solutions.
> The first one is merging the needed java archives especially the
> taglib.xml. I think this one is bad because the separation between the
> component projects is destroyed.
> The second one is merging the taglib definitions while being processed
> by FaceletTaglibConfigProcessor#processTagLibrary(). In line 308 a new
> TagLibraryImpl is created for every facelet-taglib element. This can be
> extended to use an already existing TagLibraryImpl for a specific
> namespace. This extension requires about 10 to 15 lines of code. As a
> result there will be one TagLibraryImpl for multiple facelet-taglib
> elements with the same namespace.
> The third one, my preferd one, is using the existing
> CompositeTagLibrary. As a result and in contrast to the second method
> each facelet-taglib element will be represented by a TagLibraryImpl and
> combined by CompositeTagLibrary. This requires only a minor change. In
> FaceletTaglibConfigProcessor#processTagLibrary() in line 318 the created
> TagLibraryImpl is added to the compiler. Compiler#addTagLibrary() tests
> if the given library is already known to the compiler. Subsequently this
> is done by using equals() and hashCode() in AbstractTagLibrary. At the
> moment hashCode() is implemented to use nothing except the namespace. If
> there are multiple TagLibraryImpl with the same namespace only one will
> be included in the compiler. The rest is thrown away. By extending
> hashCode() to use this.factories and this.functions in the calculation
> multiple TagLibraryImpl with different tags etc. can coexist. IMO it
> makes sense by reason taglibs are not equal only because they define the
> same namespace.
> CompositeTagLibrary handles this very well so no other changes are
> required.
> I attached a patch to modify AbstractTagLibrary#hashCode(). The
> algorithm is base on Joshua Bloch's Effective Java. The existing test
> cases are not harmed and apologize my self not writing a specific test
> case. I don't like to call it a patch because it's so stupidly simple,
> but I'd be glad if something like it could be shipped with JSF2 to
> provide this feature.
> kind regards,
> Matthias Berndt
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail: