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

标签 spring spring-boot jsf custom-component

我想创建一个自定义 JSF 2.0 组件,但无法让它工作。 我的组件是这样定义的:

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

标签库如下所示:

 <?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 管理的。

知道这里发生了什么吗?

最佳答案

[这里是移 Action 者的解决方案]

似乎 Spring 是这里的坏人。 我已经从组件中删除了注释 @FacesComponent(value = "myCustomComponent") 并在我的 faces-config 中定义它,如下所示:

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

现在可以了。

关于spring - 在 Spring Boot 中找不到带有 @FacesComponent 的 JSF 自定义组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9684402/

相关文章:

java - Spring 中的任务调度程序

java - 使用 Spring-DM 扩展器

java - 改造 Https 调用给连接重置

java - spring-boot jersey maven 无法运行 war 文件

spring-boot - 如何解决org.elasticsearch.action.search.SearchPhaseExecutionException:所有分片均失败

JSF commandLink,POST和后退按钮

jsf - Netbeans 错误 "The attribute target is not defined in the component outputStylesheet"

jsf - 数据表行扩展事件

java - Spring Cloud Contract 不检查消费者/提供者是否匹配

spring - 我可以在没有注释的情况下使用 Spring 的缓存功能吗?