Skip to content

Instantly share code, notes, and snippets.

Created May 30, 2017 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fd0efbca71f827e779b4f2d8c7feee0f to your computer and use it in GitHub Desktop.
Save anonymous/fd0efbca71f827e779b4f2d8c7feee0f to your computer and use it in GitHub Desktop.
Imo it's not possible to use tagfiles atm. Here is my workaround:
- Use a tld in current portlet. I stole the tld from a Liferay jira ticket. Had some really strange problems using my own .tld file.
/META-INF/resource/test.tld
[code]
<?xml version="1.0"?>
<!-- This does not work if file name or uri is changed??????????? -->
<taglib
version="2.1"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
>
<tlib-version>1.0</tlib-version>
<short-name>example</short-name>
<uri>http://liferay.com/tld/example</uri>
<tag-file>
<name>accordion-item</name>
<path>/META-INF/tags/accordion-item.tag</path>
</tag-file>
</taglib>
[/code]
In jsp:
[code]<%@ taglib prefix="custom" uri="http://liferay.com/tld/example" %>[/code]
For me changing tld filename from test.tld breaks the jsp (????????) also changing tld uri will add the wrong osgi require capabality into bnd so not changing these work. Don't have time to investigate this so whatever.
Also there are crazy bugs in using the custom tags:
- Using jstl tags in custom tags break randomly the tag. For example in one tag c:if is OK but c:forEach breaks. I suspect this has something to do with tags that use tag body. Same goes for your custom tags.
- Not sure if this is a bug but referring to tag attributes with ${attr} does not work, i'm using <%= attr %>. At least some sources indicate ${attr} should work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment