Applying a theme but doesn't work

UI Components for JSF
Post Reply
kimkao
Posts: 2
Joined: 22 Dec 2011, 10:10

22 Dec 2011, 10:19

I'm trying to apply a specific them to my jsf 2.x webapp.
According to the user manual, i did the following steps.

1. downoad the theme jar, and set into the classpath
2. add a context-param in web.xml , like this
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>start</param-value>
</context-param>

here are the develop environment infos.

Code: Select all

IDE : Eclipse 3.7 indigo
Web Container : Oracle WebLogic 12C
JSF Runtime : Oracle WebLogic Shared Library  , it's a default choice
Primeface : 3.0RC2
theme jar : start-1.0.2.jar
here is the presentation page ~ ref from the showcase demo

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<head>
<title><h:outputText value="#{msg.welcomeTitle}" /></title>
</head>
<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">
		</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">
			<h:form>  
            This fullPage layout consists of five different layoutUnits which are resizable and closable by default.    
        </h:form>
		</p:layoutUnit>
	</p:layout>
</body>
</html>

so, is there any suggestion that how can i solve this problem ?

kimkao
Posts: 2
Joined: 22 Dec 2011, 10:10

23 Dec 2011, 04:05

it seems to be solved.
By adding the <h:head> with xmlns:h="http://java.sun.com/jsf/html" tag , then the theme works well.
But, why should we add the empty <h:head> tag due to enforce primefaces component working ?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

23 Dec 2011, 10:11

h:head is JSF stuff, not PF related, it is vital to use JSF resource api features.

Documented at;

http://www.primefaces.org/gettingStarted.html

And user's guide.

mauromol
Posts: 26
Joined: 11 Apr 2014, 16:32

06 May 2014, 14:58

I would suggest to state clearly in the getting started guide and in the "Installation" section of http://www.primefaces.org/themes that the <h:head> tag is needed for themes to work. I wouldn't say it's documented just because the "hello world" example in the getting started guide has an empty (and apparently useless) <h:head> in it ;-)

Today I encountered this exact same problem and I solved it after several minutes thanks to kimkao hint.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

06 May 2014, 15:04

h:head is required for everything... ;) Not just PrimeFaces.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

mauromol
Posts: 26
Joined: 11 Apr 2014, 16:32

06 May 2014, 15:35

It depends on what you mean by "required". You can easily write a facelet with no <h:head> and with a PrimeFaces data table which produces no errors and renders correctly apart from theme applying.

User avatar
cerbenus
Posts: 7
Joined: 30 Aug 2012, 20:10

29 Oct 2014, 18:15

I am trying to get the downloaded dark-hive theme going but can't figure out why it won't show...Looking into the html source code I always see aristo theme, which I believe is the default theme. I followed multiple forum suggestions but have to post this one into the community - maybe someone can give me a hint.

My structure:
/webapp/WEB-INF/lib/dark-hive.jar -> downloaded from themeroller.org and converted with themeroller.osnode.com/themeroller/ into a PF theme
/webapp/WEB-INF/templates/layout.xhtml -> my master template, which contains xmlns:h="http://java.sun.com/jsf/html" namespace attribute as well as <h:head> tag
/webapp/WEB-INF/resources
/webapp/WEB-INF/web.xml
/webapp/WEB-INF/faces-config.xml
...

I don't output any CSS simply because according to the docs it's not needed for PF themes to work.

Parts of my web.xml:

Code: Select all

<context-param>
	<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
	<param-value>/WEB-INF/resources</param-value>
</context-param>
<context-param>
	<param-name>primefaces.THEME</param-name>
	<param-value>dark-hive</param-value>
</context-param>
My pom.xml:

Code: Select all

<dependency>
	<groupId>org.primefaces.themes</groupId>
	<artifactId>dark-hive</artifactId>
	<version>1.0.8</version>
</dependency>
Because of Maven dependency and manual download/drop into /WEB-INF/lib folder I now have 2 dark-hive.jar in my war file:
/WEB-INF/lib/dark-hive-1.0.8.jar
/WEB-INF/lib/dark-hive.jar

Both have the same internal structure.

I am using WildFly 8.1.0.Final with upgraded JSF Mojarra 2.2.8, PrimeFaces 5.1, OmniFaces 1.8.1

Any ideas?
PrimeFaces 5.1, Mojarra 2.2.8, WildFly 8.1.0.Final, Windows 7, IntelliJ 14

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

03 Nov 2014, 19:42

yes, remove it from the pom. Not needed if you have it in your WEB-INF/lib. Or upload it to your own repo and give it a specia version number and use that in the pom

User avatar
cerbenus
Posts: 7
Joined: 30 Aug 2012, 20:10

10 Nov 2014, 07:13

That didn't work either...
I removed the dependency entry in the pom.xml. Then I downloaded the official dark-hive-1.0.10.jar from the PF repo and copied it into /WEB-INF/lib folder. This jar is available in the maven built jar. I also removed any of my outputStylesheet tags to make sure nothing gets overridden. Still no change in behavior. Code still points to default theme Aristo.
PrimeFaces 5.1, Mojarra 2.2.8, WildFly 8.1.0.Final, Windows 7, IntelliJ 14

User avatar
cerbenus
Posts: 7
Joined: 30 Aug 2012, 20:10

18 Dec 2014, 18:28

The answer lies within the use of OmniFaces showcase HeadRenderer.

In my faces-config.xml I was using:

Code: Select all

<render-kit>
		<renderer>
			<component-family>javax.faces.Output</component-family>
			<renderer-type>javax.faces.Head</renderer-type>
			<renderer-class>org.omnifaces.showcase.HeadRenderer</renderer-class>
		</renderer>
	</render-kit>
which used the primefaces-aristo theme.
Solution was to write my own HeadRenderer according to:

https://github.com/omnifaces/omnifaces/ ... rceHandler
PrimeFaces 5.1, Mojarra 2.2.8, WildFly 8.1.0.Final, Windows 7, IntelliJ 14

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 36 guests