其他分享
首页 > 其他分享> > 在Spring Boot中找不到带有@FacesComponent的JSF自定义组件

在Spring Boot中找不到带有@FacesComponent的JSF自定义组件

作者:互联网

我想创建一个自定义的JSF 2.0组件,但无法使其工作.
我的组件定义如下:

 @FacesComponent(value = "myCustomComponent")
 public class CommaSeperatedOutput extends UIComponentBase { ... }

taglib看起来像这样:

 <?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>

我的faces-config看起来像这样:

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

我收到以下错误:

SEVERE: JSF1068: Component with componenttype myCustomComponent could not be instantiated.
javax.faces.FacesException: Expression Error: Named Object: myCustomComponent not found.

不确定它是否重要,但我在这里使用Spring 3.1和JSF 2.1.所以依赖关系由Spring管理.

知道这里发生了什么吗?

解决方法:

[移动作者的解决方案]

看起来Spring就是这里的坏人.
我从组件中删除了注释@FacesComponent(value =“myCustomComponent”),并在我的faces-config中定义它,如下所示:

<component>
    <component-type>myCustomComponent</component-type>
    <component-class>com.company.jsf.component.CommaSeperatedOutput</component-class>
</component>

现在它有效.

标签:custom-component,spring,spring-boot,jsf
来源: https://codeday.me/bug/20191006/1859550.html