Richfaces4页面的模板

时间:2012-06-22 00:59:51

标签: richfaces demo

我正在tomcat7中尝试一些richfaces4示例。 如果我将http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=panel&skin=emeraldTown的“查看源”中的代码复制到test.xhtml文件中。如果我去http://localhost/jsf-blank/test.jsf。我只会看到一个带有PLAIN TEXT的网页,而不是演示中显示的面板...

我找到了两种方法让它像演示页一样。

第一种方式是:

<!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:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
<h:head>
</h:head>
<h:body>
    <--!!!insert rich:panel tags here!!!-->
</h:body>
</html>

第二种方式是:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:rich="http://richfaces.org/rich">

 <f:view>
 <h:head></h:head>
 <h:body>
    <--!!!insert rich:panel tags here!!!-->   
 </h:body>
 </f:view>

</ui:composition>

问题: 有人可以更深入地解释为什么上面的两段代码可以工作,但直接来自演示的代码不起作用??? 看起来标记是呈现组件的关键。有人在此处提出类似问题RichFaces4 don't render the components 感谢。

1 个答案:

答案 0 :(得分:2)

您可以在Java EE 6教程的“使用Facelets模板”部分找到答案: http://docs.oracle.com/javaee/6/tutorial/doc/giqxp.html

点击“查看来源”链接时看到的是客户页面的代码,因此您还需要一个模板。