where to link to template.xhtml

Post Reply
heather_p
Posts: 7
Joined: 29 Aug 2016, 15:55

07 Jun 2019, 16:55

Hi,

In the documentation I read that you must put template.xhtml under WEB-INF. when I do that and configure the page like this, I get a blank page:

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:jsf="http://xmlns.jcp.org/jsf"
      template="/WEB-INF/template.xhtml">
As an alternative, when I put template.xhtml (and megamennu.xhtml, etc) under webapp/resources and link like this:

Code: Select all

<ui:composition template="/resources/templates/template.xhtml">
I get a page that displays the megamenu.xhtml content, but no styles are applied to <body class="main-body"> or <div class="layout-wrapper ">. When I do "inspect element" over those tags I get "no CSS properties found".

Help please.

heather_p
Posts: 7
Joined: 29 Aug 2016, 15:55

07 Jun 2019, 20:37

I am running jsf/PF 6.2. Here's what I did to get the calfornia theme working:

1. Add california-theme-2.0.0.jar to local repo via mvn install, then added it to pom.xml:

Code: Select all

<dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>california-theme</artifactId>
            <version>2.0.0</version>
        </dependency>
2. unzip california-layout-2.0.0.zip, cd into directory

cp resources/california-layout to src/main/webapp/resources/
(should be src/main/webapp/resources/california-layout/)

cp WEB-INF/footer.xhtml,WEB-INF/megamenu.xhtml,WEB-INF/right-sidebar.xhtml,WEB-INF/route-bar-menu.xhtml,WEB-INF/sidebar.xhtml,WEB-INF/template.xhtml,WEB-INF/topbar.xhtml to webapp/resources/california-layout/templates/
(should be webapp/resources/california-layout/templates/template.xhtml. These file do not need to be under WEB-INF/ as stated in documentation).

3. cd webapp/resources/california-layout/css and rm *.scss
sass does not need to be installed to simply utilize theme, as far as I can tell.

4. Create GuestPreferences.java as in https://www.primefaces.org/california/docs.xhtml

5. In my sample page, link to template like this:

Code: Select all

<ui:composition 
            xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:jsf="http://xmlns.jcp.org/jsf"
      template="/resources/templates/template.xhtml">
(no <html><body> tags above <ui:composition>)

It's not perfect but it's starting to work better. I can now see styles.


Post Reply

Return to “California - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests