在 jar 中找不到带注释的自定义 JSF2 组件
我们正在将 JSF1.2 迁移到 JSF2 应用程序,我遇到了自定义组件的问题。我们有一个带有组件的单独的 jar,在那个 jar 中我有这个:
@FacesComponent(value = "Panel2")
public class Panel2 extends UIOutput { ... }
在 META-INF 下的 taglib 中我有这个:
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
id="mw">
<namespace>http://www.ssss.be/jsf/mw</namespace>
<composite-library-name>mw</composite-library-name>
<tag>
<tag-name>panel2</tag-name>
<component>
<component-type>Panel2</component-type>
</component>
</tag>
</facelet-taglib>
如下:
xmlns:mw="http://www.ssss.be/jsf/mw"
在制作了这一切的 jar 并在我的其他项目中使用它之后,我使用标签 然后:
<mw:panel2 />
但结果不幸的是:
javax.faces.FacesException: Expression Error: Named Object: Panel2 not found. at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1858)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1129)
我在这里做错了什么?
We are migrating JSF1.2 to JSF2 application and I have bumped into a problem with custom components. We have a seperate jar with components, and in that jar I have this:
@FacesComponent(value = "Panel2")
public class Panel2 extends UIOutput { ... }
In my taglib under META-INF I have this:
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
id="mw">
<namespace>http://www.ssss.be/jsf/mw</namespace>
<composite-library-name>mw</composite-library-name>
<tag>
<tag-name>panel2</tag-name>
<component>
<component-type>Panel2</component-type>
</component>
</tag>
</facelet-taglib>
After making a jar of this all and use it in my other project, I use the tag as follows:
xmlns:mw="http://www.ssss.be/jsf/mw"
And then:
<mw:panel2 />
But the result is unfortunately:
javax.faces.FacesException: Expression Error: Named Object: Panel2 not found. at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1858)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1129)
What am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
metadata-complete
属性设置为 true。WEB-INF/lib
中的 jar 中,则该 jar 包含 faces-config.xml (规范不需要注释扫描,否则)Panel2
在 XML 配置文件中定义的组件类型(此列表优先)请参阅 JSF 2 规范;第 11.5.1 节。
metadata-complete
attribute in faces-config.xml set to true.WEB-INF/classes
; or, if in a jar inWEB-INF/lib
, that the jar contains a faces-config.xml (the spec doesn't require annotation scanning otherwise)Panel2
component-type defined in an XML configuration file (this listing will take precedence)See the JSF 2 spec; section 11.5.1.