ICEfaces配置为查看/index.xhtml但h:head和h:body组件是必需的

时间:2015-01-07 10:34:41

标签: jsf icefaces

我正在尝试将ICEFaces ACE组件库集成到我的项目中。我有以下观点:

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
<head>

<h:outputStylesheet library="org.icefaces.component.skins"
    name="rime.css" />

<f:loadBundle basename="resources.application" var="msg" />
<title>
        <h:outputText value="#{msg.templateTitle}" />
</title>
</head>

<body>
    <div id="content">
        <h:form>
            <ace:dataTable var="user" value="#{userBean.users}"
                paginator="true" rows="50" selectionMode="multiple">
                <ace:column headerText="users">
                    <ace:row>#{user}</ace:row>
                </ace:column>
            </ace:dataTable>
        </h:form>
    </div>

</body>

</html>

不幸的是,显然没有加载JavaScript / CSS,因此组件显示不正确。此外,服务器记录此:

  

为视图/index.xhtml配置的ICEfaces但h:head和h:body组件是必需的

这有关系吗?

1 个答案:

答案 0 :(得分:1)

您需要使用JSF <h:head><h:body>组件,而不是纯HTML <head><body>。这样,JSF和任何JSF组件库都能够以编程方式自动包含CSS / JS资源。

E.g。

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core">
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
>
    <f:loadBundle basename="resources.application" var="msg" />

    <h:head>
        <title>#{msg.templateTitle}</title>
    </h:head>

    <h:body>
        ...
    </h:body>
</html>

请注意,这样您也不再需要<h:outputStylesheet>了。

另见:


对于具体问题

无关,您最好在resources.application中将<resource-bundle>声明为faces-config.xml,这样您就不需要重复了所有观点。另请注意,您不一定需要<h:outputText>所有地方。 <head>以及上述所有内容也表明您正在学习基于JSF 1.x目标教程的JSF,而不是2.x目标教程。确保您使用正确的资源进行学习。