Hi,
I try to adapt the idea in this url to my portlet :
https://newfivefour.com/tomcat7-el-custom-function.html
In my portlet I create this class in package named pck :
public class Common {
public static String getDateFormat(String oldDateString) throws ParseException {
final String OLD_FORMAT = "yyyy-MM-dd";
final String NEW_FORMAT = "dd/MM/yyyy";
String newDateString;
SimpleDateFormat sdf = new SimpleDateFormat(OLD_FORMAT);
Date d = sdf.parse(oldDateString);
sdf.applyPattern(NEW_FORMAT);
newDateString = sdf.format(d);
return newDateString;
}
}
So I created a file in WEF_INF folder named : taglib.tld
<?xml version="1.0" encoding="UTF-8"?>
<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>common</short-name>
[u]<uri>/</uri>[/u]
<function>
<name>getDateFormat</name>
<function-class>
pck.Common
</function-class>
<function-signature>
java.lang.String getDateFormat(java.lang.String)
</function-signature>
</function>
</taglib>
And I modified my web.xml with
</web-app>
...
<jsp-config>
<taglib>
<taglib-uri>
[u]http://myurl[/u]
</taglib-uri>
<taglib-location>
/WEB-INF/taglib.tld
</taglib-location>
</taglib>
</jsp-config>
</web-app>
And I modified a data in portlet with the following expression : #{a:getDateFormat(myVariable)}
But I need help about somethings :
- Is taglib work with CAF ?
- in uri tag in taglib (underline in taglib.tld file) I don’t know what to make
- in taglib-uri tab in web.config (underline in web.xml file) I don’t know what to make
- In the link I put :
I need to make this statement in html file :
<%@ taglib uri="http://myurl" prefix="a" %>
But I dont know where