在Spring Boot中找不到带有@FacesComponent的JSF自定义组件 [英] JSF custom component with @FacesComponent is not found in Spring Boot

查看:198
本文介绍了在Spring Boot中找不到带有@FacesComponent的JSF自定义组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个自定义JSF 2.0组件,但无法使其正常工作. 我的组件是这样定义的:

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 { ... }

taglib看起来像这样:

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>

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

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>

我收到以下错误:

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管理.

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.

有什么想法吗?

推荐答案

[将作者的解决方案移至此处]

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

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>

现在可以使用了.

这篇关于在Spring Boot中找不到带有@FacesComponent的JSF自定义组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆