Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF custom component with @FacesComponent is not found in Spring Boot

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?

like image 350
flash Avatar asked Mar 13 '12 12:03

flash


1 Answers

[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.

like image 136
The Student Avatar answered Oct 21 '22 01:10

The Student