Forums

Home » Liferay Portal » English » Liferay Legacy

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
David F
Creating/Modifying taglib in ext environment
January 25, 2007 11:04 AM
Answer

David F

Rank: New Member

Posts: 14

Join Date: December 15, 2006

Recent Posts

Can someone tell me if there's a way to extend or modify Liferay taglibs in the extension environment? I looked in the documentation, but couldn't find anything. Any help would be appreciated, thanks!
javier de Ros
RE: Creating/Modifying taglib in ext environment
February 22, 2007 7:51 AM
Answer

javier de Ros

Rank: New Member

Posts: 2

Join Date: February 22, 2007

Recent Posts

I'm the same problem. How can I make externals tagbils from the theme?emoticon
Shane W
RE: Creating/Modifying taglib in ext environment
April 12, 2007 1:26 PM
Answer

Shane W

Rank: New Member

Posts: 16

Join Date: October 19, 2006

Recent Posts

Here’s how I created custom taglibs in the ext environment. I was trying to create my own search iterator, which I use as an example below.

You’ll see in step 3 that I sorta hacked some stuff because I couldn’t get the linking to work. I couldn’t get files in ext-ejb to see java files in portal/util-taglib. Hopefully someone who knows more about this can solve this problem.

1. Create the new page.jsp:
a. Create a taglib folder in ext-web/docroot/html/
b. Then add other files/folders as needed
c. Ex: ext-web/docroot/html/taglib/ui/my_search_iterator/page.jsp
i. page.jsp is just a slightly modified version of the regular search_iterator/page.jsp

2. Create the new *.tld file
a. Created the following folder: ext-web/WEB-INF/tld
b. Add your modified *.tld
c. Ex: liferay-ui-ext.tld
d. Mine looked like:
 1<taglib>
 2    <tlibversion>1.0</tlibversion>
 3    <jspversion>1.1</jspversion>
 4    <shortname>liferay-ui-ext</shortname>
 5    <uri>http://liferay.com/tld/ui-ext</uri>
 6    <tag>
 7        <name>my-search-iterator</name>
 8        <tagclass>com.ext.taglib.ui.MySearchIteratorTag</tagclass>
 9        <bodycontent>JSP</bodycontent>
10        <attribute>
11            <name>page</name>
12            <required>false</required>
13            <rtexprvalue>true</rtexprvalue>
14        </attribute>
15        <attribute>
16            <name>searchContainer</name>
17            <required>true</required>
18            <rtexprvalue>true</rtexprvalue>
19        </attribute>
20    </tag>
21</taglib>


3. Create the corresponding java files
a. I hacked this because I couldn’t figure out how to get my files to recognize files that already existed in util-taglib. Someone who knows the build files want to help with this?
b. Create: ext-ejb/src/com/ext/taglib
c. Add the appropriate files
d. I added MySearchIteratorTag.java & just changed the _PAGE to point to the page.jsp specified above.
e. However, to get things to compile I also copied SearchFormTag.java from util-taglib/src/com/liferay/taglib/ui & the directory & all files in util-taglib/src/com/liferay/taglib/util
i. I just changed the package for these files and the include paths to specify the right version.
ii. There’s got to be a way to reference the originals, I just don’t know it.
iii. I commend out the VelocityTaglib part of ThemeUtil.java because VelocityTaglib included a ton of dependencies I didn’t want to copy over and I’m not using velocity themes.

4. Update web.xml
a. Edit ext-web/WEB-INF web.xml to include references to your new taglib.
b. Eg:
1<taglib>
2    <taglib-uri>http://liferay.com/tld/ui-ext</taglib-uri>
3    <taglib-location>/WEB-INF/tld/liferay-ui-ext.tld</taglib-location>
4</taglib>



5. Edit init-ext.jsp to include the taglib
a. Ext-web/temp/html/common/init-ext.jsp
b. I added the line:
i.
1<%@ taglib uri="http://liferay.com/tld/ui-ext" prefix="liferay-ui-ext" %>


That did the trick for me. If anyone can tell me how to clean up the linking in step 3 so I don’t need to include a bunch of redundant files that would be great.

Hope that helps
claudia wagner
RE: Creating/Modifying taglib in ext environment
April 17, 2008 2:03 AM
Answer

claudia wagner

Rank: New Member

Posts: 6

Join Date: April 13, 2008

Recent Posts

It is not necessary to copy the complete ui and util folder from util-taglib/src/com/liferay/taglib to the ext folder.
I extended the discussion taglib in the following way and it works:

1. Create a taglib/ui folder in ext-web/docroot/html/
2. Create the new page.jsp or copy page.jsp from the taglib you want to modify (for example from portal-web/docroot/html/taglib/ui/discussion)
3. ext-web/docroot/html/taglib/ui/discussion-ext/page.jsp
4. page.jsp is just a slightly modified version of the regular portal-web/docroot/html/taglib/ui/discussion/page.jsp
5. Create the new *.tld file
6. Created the following folder: ext-web/WEB-INF/tld
7. Add your modified *.tld
8. example liferay-ui-ext.tld could look like this:

<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.1</jsp-version>
<short-name>liferay-ui-ext</short-name>
<uri>http://liferay.com/tld/ui-ext</uri>
<tag>
<name>discussion-ext</name>
<tag-class>com.ext.taglib.ui.DiscussionTagEXT</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>page</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>formName</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>formAction</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>className</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>classPK</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>userId</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>subject</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>redirect</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>

9. The short-name and the uri on the top of the file, define the name and the uri of the taglib!!!!
10. the name of the tag is defined for each tag member of the taglib.
11. for example liferay-ui-ext:discussion-ext references the tag tag discussion-ext from the taglib liferay-ui-ext
12. copy the java files, which belong to the taglib, from util-taglib/src/com/liferay/taglib/ui/ (example DiscussionTag.java)
to ext-impl/src/com/ext/taglib/ui and rename the class so, that the classname corresponds with the
<tag-class>com.ext.taglib.ui.DiscussionTagEXT</tag-class> from the tld file specified before.
13.Update web.xml in the ext-web/docroot/WEB_INF folder so that the server knows where the taglib is located

<web-app>
<taglib>
<taglib-uri>http://liferay.com/tld/ui-ext</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-ui-ext.tld</taglib-location>
</taglib>
</web-app>

14. Edit init-ext.jsp (in portal-web/docroot/html/portlet) to include the taglib.
<%@ taglib uri="http://liferay.com/tld/ui-ext" prefix="liferay-ui-ext" %>
There is also a init-ext.jsp in portal-web/docroot/html/taglib, but this is not the right one.

Hope this helps!
Tejas H Kanani
RE: Creating/Modifying taglib in ext environment
November 10, 2008 1:51 AM
Answer

Tejas H Kanani

Rank: New Member

Posts: 20

Join Date: March 10, 2008

Recent Posts

hi all,

I want to modify themeUtil.java file which is in portal (portal\util-taglib\src\com\liferay\taglib\util) and i want to put that file in ext
then what folder structure should i follow to create it in ext.

and do i need to change the tld file ???

thanks,
Srikanth Reddy Sanivarapu
RE: Creating/Modifying taglib in ext environment
February 9, 2009 9:44 PM
Answer

Srikanth Reddy Sanivarapu

Rank: Regular Member

Posts: 193

Join Date: November 14, 2008

Recent Posts

Tejas H Kanani:
hi all,

I want to modify themeUtil.java file which is in portal (portal\util-taglib\src\com\liferay\taglib\util) and i want to put that file in ext
then what folder structure should i follow to create it in ext.

and do i need to change the tld file ???

thanks,


Hi Tejas ,

Did u get the solution for this.

If u got the solution plz reply me with solution for this..?

Thanks & Regards,
Srikanth Reddy.S
Tejas Kanani
RE: Creating/Modifying taglib in ext environment
February 15, 2009 2:41 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Tejas H Kanani:
Hi Tejas ,

Did u get the solution for this.

If u got the solution plz reply me with solution for this..?

Thanks & Regards,
Srikanth Reddy.S


so here is the solution ...

you'll need to put that modified ThemeUtil.java in ext-impl/src/com/liferay/taglib/util/
so your complete path for ThemeUtil.java file would be /ext-impl/src/com/liferay/taglib/util/ThemeUtil.java

Then just deploy ext ....
Thats it ...
Joyita Sikder
RE: Creating/Modifying taglib in ext environment
June 15, 2011 3:40 PM
Answer

Joyita Sikder

Rank: New Member

Posts: 1

Join Date: December 2, 2010

Recent Posts

Hi All,

I created a custom taglib in the ext-plugin environment. I am able to use the taglib in the hooks jsp.
If I use the custom taglib in portlet-plugin I get the following error in my tomcat console "No tag "customTab" defined in tag library imported with prefix "liferay-ui".

Please let me know if I am missing out something.

Thanks in advance !!

Thanks,
Joyita