【问题标题】:jsf-2.2: f:view contracts attribute found, but not used at top leveljsf-2.2:找到 f:view 合同属性,但未在顶层使用
【发布时间】:2015-03-14 23:05:42
【问题描述】:

您好,我每次在网页上输入时都会在服务器控制台中收到以下信息:f:view contracts attribute found, but not used at top level

我正在使用 jsf 模板,我有一个这样的 default.xhtml 模板文件:

<!DOCTYPE html>
<html ...xmlns...>
<f:view contracts="default" locale="#{bbClevcore.locale}">
  <h:head>
    ...
  </h:head>
  <h:body id="body">
    <header>
      ...
    </header>

    <section>
      <h:panelGroup layout="block">
        <h:panelGroup id="section" layout="block">
          <ui:insert name="section" />
        </h:panelGroup>
      </h:panelGroup>
    </section>

    <footer>
      ...
    </footer>
    </ui:insert>

  </h:body>
</f:view>
</html>

我有以下合约目录:

-src/main/webapp/contracts/default/common/css/main.css

在实际页面中:index.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:cc="http://xmlns.jcp.org/jsf/composite/components"
    template="/templates/default.xhtml">
    ...
    <ui:define name="section">
       ....
    </ui:define>
</ui:composition>

合同有效,因为当我将合同值从 default 更改为让说 alternative 时,在备用文件夹中有另一个 main.css,页面会进行更改并显示另类的风格。我在正确的位置使用 f:view 吗?

谢谢

【问题讨论】:

    标签: jsf jsf-2.2 contracts


    【解决方案1】:

    无法在全局模板中设置合同。 JSF 允许 仅将其设置在第一个请求的文件(模板客户端)中。试试这个!

    模板:

    <!DOCTYPE html>
    <html ...xmlns...>
      <h:head>
        ...
      </h:head>
    
      <h:body id="body">
        <header>
          ...
        </header>
    
        <section>
          <h:panelGroup layout="block">
            <h:panelGroup id="section" layout="block">
              <ui:insert name="section" />
            </h:panelGroup>
          </h:panelGroup>
        </section>
    
        <footer>
          ...
        </footer>
    
      </h:body>
    </html>
    

    模板-客户端:

    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://xmlns.jcp.org/jsf/core"
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    
        <f:view contracts="alternative">
            <ui:composition template="/templates/default.xhtml">
                ...
                <ui:define name="section">
                   ....
                </ui:define>
                ...
            </ui:composition>
        </f:view>
    
    </ui:composition>
    

    【讨论】:

      猜你喜欢
      • 2013-10-13
      • 2015-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多