Ger*_*rep 15 layout jsf templates facelets primefaces
我需要像创建布局这个,但所有的分隔的文件,如容器:
top.xhtml
<p:layout fullPage="true">
<p:layoutUnit position="north" header="#{support.applicationTitle}">
<h:form>
<p:menubar>
<p:menuitem value="Quit" icon="ui-icon-close" action="#{userController.logOut()}" />
</p:menubar>
</h:form>
</p:layoutUnit>
Run Code Online (Sandbox Code Playgroud)
没有</p:layout>
因为它将在我的footer.xhtml上关闭像:
<p:layoutUnit position="south" header="© 2012 - 2012 PORTAL DE IDEIAS">
</p:layoutUnit></p:layout>
Run Code Online (Sandbox Code Playgroud)
我试过这两个文件,但是我收到一个错误,告诉我需要关闭布局标签,这是正确的,但我怎样才能解决我的问题?这是模板的最佳方法吗?另一个问题是布局标签需要一个中心layoutUnit
Bal*_*usC 30
这确实不是正确的方法.您的模板必须是XML格式良好.我建议创建一个主模板文件,如果你想要的只是指定中心单元.
以展示网站为例,它应该如下所示:
/WEB-INF/templates/layout.xhtml
<!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"
xmlns:p="http://primefaces.org/ui"
>
<h:head>
<title>Title</title>
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100" header="Top" resizable="true" closable="true" collapsible="true">
<h:outputText value="Top unit content." />
</p:layoutUnit>
<p:layoutUnit position="south" size="100" header="Bottom" resizable="true" closable="true" collapsible="true">
<h:outputText value="South unit content." />
</p:layoutUnit>
<p:layoutUnit position="west" size="200" header="Left" resizable="true" closable="true" collapsible="true">
<h:form>
<ui:include src="../templates/themeMenu.xhtml" />
</h:form>
</p:layoutUnit>
<p:layoutUnit position="east" size="200" header="Right" resizable="true" closable="true" collapsible="true" effect="drop">
<h:outputText value="Right unit content." />
</p:layoutUnit>
<p:layoutUnit position="center">
<ui:insert name="content">Put default content here, if any.</ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
请注意<ui:insert>
中央单元.
模板客户端可以看起来像这样:
/page.xhtml
<ui:composition template="/WEB-INF/templates/layout.xhtml"
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"
xmlns:p="http://primefaces.org/ui"
>
<ui:define name="content">
<p>Here goes your view-specific content.</p>
</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
您可以通过http://example.com/contextname/page.xhtml打开它.
如果您正在寻找高级Facelets模板的实时开源示例,您可能会发现OmniFaces展示应用程序非常有用.