I am trying to create a custom JSF component and add a method expression to it. This is the code of my custom component:
@FacesComponent(AjaxCommand2.COMPONENT_TYPE) public class AjaxCommand2 extends UIComponentBase { public static final String COMPONENT_TYPE = "local.test.component.AjaxCommand2"; public static final String COMPONENT_FAMILY = "local.test.component.AjaxCommand2"; private MethodExpression listener; public MethodExpression getListener() { return listener; } public void setListener(MethodExpression listener) { this.listener = listener; } @Override public String getRendererType() { return null; } @Override public String getFamily() { return COMPONENT_FAMILY; } }
This is the file of my lib tag:
<?xml version="1.0" encoding="UTF-8"?> <facelet-taglib id="test" 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-facelettaglibrary_2_0.xsd" version="2.0"> <namespace>http://local.test/ui</namespace> <tag> <tag-name>ajaxCommand2</tag-name> <component> <component-type>local.test.component.AjaxCommand2</component-type> </component> <attribute> <name>listener</name> <required>false</required> <type>javax.el.MethodExpression</type> </attribute> </tag> </facelet-taglib>
And this is the corresponding code on the JSF page:
<test:ajaxCommand2 listener="#{testSessionBean.testActionAjax}" />
My problem is that the installer for the listener is never called in my custom component, and I always get zero in the listener property.
I do not see what the problem is. Any idea ?, I would like to set the listener property to point to the specific method of one supported bean.
source share