Using function in EL in portlet

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 :

  1. Is taglib work with CAF ?
  2. in uri tag in taglib (underline in taglib.tld file) I don’t know what to make
  3. in taglib-uri tab in web.config (underline in web.xml file) I don’t know what to make
  4. 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

OK I fix some issues, I feel I am close to find the solution but it doesn’t come.

OK As the first comment, I create the following Class in package we will call pkg

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;  
    }  
}  

Then I migrate my view to be in JSF 2. I can see a xhtml file for my view (instead of a xml file).

Then I create a file in /WEB-INF called common.taglib.xml like this :


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE facelet-taglib PUBLIC
  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
  "https://facelets.dev.java.net/source/browse/*checkout*/facelets/src/etc/facelet-taglib_1_0.dtd">
<facelet-taglib xmlns="http://java.sun.com/JSF/Facelet">
    <namespace>http://url-which-doesnt-exist-in-relaity-but-exist-for-my-namespace</namespace>
    <function>
        <function-name>getDateFormat</function-name>
        <function-class>pkg.Common</function-class>
        <function-signature>java.lang.String getDateFormat(java.lang.String)</function-signature>
    </function>
</facelet-taglib>

As you see, the url : http://url-which-doesnt-exist-in-relaity-but-exist-for-my-namespace is not a real url it is just a namespace.

Then I modify my web.xml file and add the following tags :


  <context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/common.taglib.xml</param-value>
  </context-param>

Then in my xhtml view fille I add the following namespace :


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:caf_f="http://webmethods.com/jsf/caf/core"
	xmlns:caf_h="http://webmethods.com/jsf/caf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	[b]xmlns:a="http://url-which-doesnt-exist-in-relaity-but-exist-for-my-namespace"[/b]>
....

And In my variable Toto in Binding view I add the following expression :

#{a:getDateFormat("2018-01-01")}

But it seems that doesn’t work :
In full.log file in server, I have the following error :

javax.el.ELException: Function ‘a:getDateFormat’ not found

So I guess I forgot something, maybe it is the url in namespace but I don’t know how to fix it.