问题
I am coding an application using Liferay 7 and OSGi modules. I need to create a custom taglib available across all modules (portlets), but I have litteraly no idea where to start.
Do you have any idea?
Should I store the taglib definition, classes and JSPs in an OSGi modules? And if not, where, and how can I reference it from a portlet module?
Thank you very much
回答1:
In most cases you should be able to deliver a taglib completely within an OSGi module. You can find several examples in Liferay's source code where this is done, such as the following:
https://github.com/liferay/liferay-portal/tree/master/modules/apps/foundation/map/map-taglib
As you can see in that example, you can declare that the module will export the taglib by using Provide-Capability in the bnd.bnd file:
Provide-Capability: osgi.extender;osgi.extender="jsp.taglib";uri="http://liferay.com/tld/map";version:Version="${Bundle-Version}"
来源:https://stackoverflow.com/questions/38522892/creating-a-custom-taglib-in-liferay-7