1

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>
4

1 に答える 1