【问题标题】:ui:insert is not rendering in the main templateui:insert 不在主模板中呈现
【发布时间】:2016-02-11 14:20:11
【问题描述】:

一年之后,我再次开始在 JSF 中工作并面临 facelets 使用方面的问题 下面是 maintemplate.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:ui="http://java.sun.com/jsf/facelets">
  <h:head>
  <title><ui:insert name="title" /></title>
  </h:head>
   <ui:insert name="header" /> 
    <body>

     content
    </body>
</html>

下面是另一个xhtml文件的ui:composition

enter code here
<?xml version="1.0" encoding="UTF-8" ?>
  <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:p="http://primefaces.org/ui"
            template="/index.xhtml">


    <ui:define name="title"><h:outputText value="Please Sign In" /></ui:define>
    <ui:define name="header"><h:outputText value="Please Sign In" /></ui:define>
  </ui:composition>

相同的内容适用于 ui:include 但不适用于 ui:defin 和 ui:insert 组合

【问题讨论】:

  • 浏览器中的右键页面,你看到了什么?是未解析的 XHTML 源代码还是生成的 HTML 输出?
  • @BalusC 浏览器已生成 HTML 输出

标签: jsf jsf-2 primefaces facelets


【解决方案1】:

我以错误的方式使用标签需要在插入中包含包含标签才能获得正确的模板功能

【讨论】:

    猜你喜欢
    • 2012-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-26
    • 2018-10-08
    • 1970-01-01
    • 2013-04-15
    • 2015-01-10
    相关资源
    最近更新 更多