fla*_*ash 14 jsf spring custom-component spring-boot
我想创建一个自定义的JSF 2.0组件,但无法使其工作.我的组件定义如下:
@FacesComponent(value = "myCustomComponent")
public class CommaSeperatedOutput extends UIComponentBase { ... }
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
我的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>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
SEVERE: JSF1068: Component with componenttype myCustomComponent could not be instantiated.
javax.faces.FacesException: Expression Error: Named Object: myCustomComponent not found.
Run Code Online (Sandbox Code Playgroud)
不确定它是否重要,但我在这里使用Spring 3.1和JSF 2.1.所以依赖关系由Spring管理.
知道这里发生了什么吗?
解:
看起来Spring就是这里的坏人.我已从__CODE__
组件中删除了注释,并在我的faces-config中定义了它,如下所示:
@FacesComponent(value = "myCustomComponent")
public class CommaSeperatedOutput extends UIComponentBase { ... }
Run Code Online (Sandbox Code Playgroud)
现在它有效.
8bi*_*kie -2
或者,由于您已将 faces-config.xml 文件配置为使用 Spring 容器,因此您可以使用 Spring 注释@Component("myCustomComponent")
归档时间: |
|
查看次数: |
3475 次 |
最近记录: |