Search code examples
jsf-2primefacesmobile-website

Templates in primefaces mobile


How to create templates in primefaces mobile, since the root tag is f:view, and not the html.


Solution

  • The XML root element doesn't matter. It merely holds the XML name space declarations. The key is that you should have a <f:view renderKitId="PRIMEFACES_MOBILE"> in the master template. So the following kickoff example of the master template should work as good:

    <f:view 
        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:pm="http://primefaces.org/mobile"
        renderKitId="PRIMEFACES_MOBILE"
    >
        <ui:insert name="some" />
    </f:view>
    

    Template client looks just the same as usual:

    <ui:composition template="/WEB-INF/template.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:pm="http://primefaces.org/mobile"
    >
        <ui:define name="some">
            ...
        </ui:define>
    </ui:composition>