I want to create a custom JSF 2.0 component but can't get it to work. My component is defined like this:
@FacesComponent(value = "myCustomComponent")
public class CommaSeperatedOutput extends UIComponentBase { ... }
The taglib looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<facelet-taglib 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://www.company.com/tags</namespace>
<tag>
<tag-name>custom</tag-name>
<component>
<component-type>myCustomComponent</component-type>
</component>
</tag>
</facelet-taglib>
My faces-config looks like this:
<faces-config version="2.0" 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-facesconfig_2_0.xsd">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
I get the following error:
SEVERE: JSF1068: Component with componenttype myCustomComponent could not be instantiated.
javax.faces.FacesException: Expression Error: Named Object: myCustomComponent not found.
Not sure if it is important, but I'm using Spring 3.1 together with JSF 2.1 here. So dependencies are managed by Spring.
Any idea what is happening here?
[moving author's solution here]
Seems like Spring is the bad guy here.
I've removed the annotation @FacesComponent(value = "myCustomComponent")
from the component and defined it instead in my faces-config like this:
<component>
<component-type>myCustomComponent</component-type>
<component-class>com.company.jsf.component.CommaSeperatedOutput</component-class>
</component>
Now it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With