【发布时间】:2014-11-11 12:18:03
【问题描述】:
我正在使用 PrimeFaces Mobile(社区 PrimeFaces 5.1)开发移动应用程序,并成功使用不同页面之间的导航。现在我想创建一个包含固定顶部和菜单的模板,并在我的所有页面上重复使用它。
最好的方法是使用嵌套页面?还有其他选择吗?
如果有人可以向我展示一个使用带有固定顶部和/或菜单的模板 PrimeFaces Mobile 的简单示例,我将不胜感激。 我的代码如下
templateMobile.xhtml
<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:p="http://primefaces.org/ui"
xmlns:pm="http://primefaces.org/mobile">
<f:view renderKitId="PRIMEFACES_MOBILE" />
<h:head>
<title>.....</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<h:body>
<pm:page id="main">
<pm:content>
<h:form id="formMobile">
<!-- I want to reuse it on all pages -->
<ui:include src="top.xhtml" />
<ui:include src="menu.xhtml" />
</h:form>
</pm:content>
</pm:page>
<pm:page id="content">
<pm:content>
<h:form id="formMobile">
<!-- don´t want to include it on all pages -->
<ui:include src="top.xhtml" />
<ui:include src="menu.xhtml" />
<!-- don´t want to include it on all pages -->
<p:growl id="messages"
showDetail="true"
showSummary="false"
autoUpdate="true" />
<!-- dynamic content -->
<ui:insert name="contentForm" />
</h:form>
</pm:content>
</pm:page>
</h:body>
</html>
page1.xhtml
<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:p="http://primefaces.org/ui"
xmlns:pm="http://primefaces.org/mobile"
template="templateMobile.xhtml">
<ui:define name="contentForm">
...
</ui:define>
</ui:composition>
【问题讨论】:
-
查看 jQuery Mobile 中的工具栏小部件。 demos.jquerymobile.com/1.4.5/toolbar-external
标签: mobile jsf-2 facelets primefaces-mobile