简体   繁体   English

JSF复合组件

[英]JSF Composite Component

I'm trying to create a composite component for use in my Seam application, and I'm running into problems with the simplest "hello, world" component. 我正在尝试创建一个复合组件,以便在我的Seam应用程序中使用,而我遇到了最简单的“hello,world”组件的问题。

I have placed a file named hello.xhtml in {jboss deploy}/application.ear/application.war/resources/greet : 我在{jboss deploy} /application.ear/application.war/resources/greet中放置了一个名为hello.xhtml的文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:composite="http://java.sun.com/jsf/composite">
<head>
<title>My First Composite Component</title>
</head>
<body>

<composite:interface>
    <composite:attribute name="who"/>
</composite:interface>

<composite:implementation>
    <h:outputText value="Hello, #{cc.attrs.who}!"/>
</composite:implementation>

</body>
</html>

Now in home.xhtml, located at the root of my webapp ({jboss deploy}/application.ear/application.war/home.xhtml): 现在在home.xhtml中,位于我的webapp的根目录({jboss deploy} /application.ear/application.war/home.xhtml):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:g="http://java.sun.com/jsf/composite/greet"
            xmlns:s="http://jboss.com/products/seam/taglib"
            template="layout/template.xhtml">
    <ui:define name="content">
    <div id="content">
        <g:hello who="World"/>
        <br/>
    </div>
    </ui:define>
</ui:composition>

But my "hello, world" is not displayed, and I dont get any error messages, even when I turn on debug level logging for com.sun and javax.faces categories. 但是我的“你好,世界”没有显示,我也没有收到任何错误消息,即使我打开com.sun和javax.faces类别的调试级别日志记录。

I've verified that the resources directory is in the proper place, since adding the directory resources/images/test.jpg, then adding this to home.xhtml: 我已经验证资源目录在适当的位置,因为添加目录resources / images / test.jpg,然后将其添加到home.xhtml:

h:graphicImage value="#{resource['images:test.jpg']}"/>

Results in the image being displayed. 显示图像的结果。 I just don't know why JSF isn't picking up my xhtml file from the greet directory. 我只是不知道为什么JSF没有从greet目录中获取我的xhtml文件。

Any ideas? 有任何想法吗?

尝试将其放入META-INF/resources ,而不仅仅是resources

以下是登录复合组件的示例,其中还解释了jsf2资源: http//jugojava.blogspot.com/2011/09/jsf-composite-component-binding-to.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM