[SOLVED] Thoughts on best practice for skinning?

UI Components for JSF
Post Reply
mbeedub
Posts: 93
Joined: 28 Jan 2010, 23:54

29 Jan 2010, 00:41

Hi

We're working on mixing PrimeFaces with RichFaces in a JBOSS/Seam environment. Wonder what anyone's thoughts were on best practice for skinning so that we can get the components from PF and RF looking consistent.

Specifically we were just looking at layout component and wanted to update the CSS in that and dad thought of an additional CSS file to be included in the template as in:

Page.xhtml:

Code: Select all

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    template="/layout/template.xhtml">

  <ui:define name="head">
  .
  .
  </ui:define>

  <ui:define name="body">
  .
  .
  </ui:define>
</ui:composition>
template.xhtml:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:a="http://richfaces.org/a4j"
   xmlns:s="http://jboss.com/products/seam/taglib"
   xmlns:p="http://primefaces.prime.com.tr/ui"
   contentType="text/html">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>mbw_ui</title>
	<link rel="shortcut icon" href="#{request.contextPath}/favicon.ico"/>
	<a:loadStyle src="resource:///stylesheet/theme.xcss"/>
	<a:loadStyle src="/stylesheet/theme.css"/>
	<a:loadStyle src="/stylesheet/fullcalendar.css"/>
	<a:loadScript src="/js/fullcalendar.min.js" /> 
	<a:loadStyle src="/stylesheet/pf-rf-central.css"/>
	<p:resources />
	<ui:insert name="head"/>
</head>

<body>   
	<p:layout fullPage="true">  

		<p:layoutUnit position="north">
		</p:layoutUnit>  

		<p:layoutUnit position="south">  
		</p:layoutUnit>  

		<p:layoutUnit position="west">  
			<h:outputText value="West unit content" />  
		</p:layoutUnit>  

		<p:layoutUnit position="east">  
			<h:outputText value="East unit content" />  
		</p:layoutUnit>  

		<p:layoutUnit position="center">  
		</p:layoutUnit>  
	</p:layout> 
</body>
</html>
</f:view>
pf-rf-central.css:

Code: Select all

/* Rich Faces - Prime Faces Consistency CSS */

body {
	margin: 0 0 0 0;
	width: 990px;
}

/**** Layout ****/

.pf-layout-resizer{background:#f68f1d;border:none;}
.pf-layout-toggler{background:#AAA;}
.pf-layout-pane{padding:10px;background:#FFF;border:1px solid #BBB;overflow:auto;}


/***** END Layout ****

Interestingly, this doesn't work. While the body CSS (width 990px etc) does work the .pf-layout-* CSS does not. If the .pf-layout-* css is put in the <head> of page.xhtml it does work.

So a couple of questions:

1) What are we doing wrong here such that it doesn't work

2) Is this the right approach to attempting to skin PrimeFaces or can folks recommend better alternatives?

Many thanks
Martin
JBoss EAP 6.4.0 | Mojarra 2.1.28 | PrimeFaces 6.2.3

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

29 Jan 2010, 10:24

Hi,

Clear, it depends on order of included css files. Try to change the order like this

Code: Select all

   <p:resources />
   <a:loadStyle src="/stylesheet/pf-rf-central.css"/>
Important thing is that you have the same CSS classes (selectors) as PrimeFaces default one (or stronger).
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

mbeedub
Posts: 93
Joined: 28 Jan 2010, 23:54

29 Jan 2010, 14:12

Hi

Thanks Oleg. Tried reordering with .css after <p:resources /> but same result.

body styles working OK but .pf-layout-resizer{background:#f68f1d;border:none;} isn't.

If I put <style>.pf-layout-resizer{background:#f68f1d;border:none;}</style> in <ui:define name="head"> </ui:define> of page.xhtml it works ok?

Any thoughts?

Cheers
Martin
JBoss EAP 6.4.0 | Mojarra 2.1.28 | PrimeFaces 6.2.3

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

29 Jan 2010, 15:15

Oleg's suggestion should have worked, it's about ordering, last added css overrides previous ones. Usually in cases like this I open firebug and see what class applies where. That'll definitely help.

Also can you post the rendered <head></head> html content.

mbeedub
Posts: 93
Joined: 28 Jan 2010, 23:54

29 Jan 2010, 15:36

Checked in FireBug. It shows the PF resources are coming after the included CSS file even though they are below it in the template code (FireBug also confirms that the resizer in my example is picking up it's CSS from the PF resources layout.css).

Rendered head code attached.

Code: Select all

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>mbw_ui</title>
	<script src="/j/a4j/g/3_3_2.SR1/org/ajax4jsf/framework.pack.js" type="text/javascript"></script>
	<script src="/j/a4j/g/3_3_2.SR1/org/richfaces/ui.pack.js" type="text/javascript"></script>
	<link class="component" href="/j/a4j/s/3_3_2.SR1/org/richfaces/skin.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__" rel="stylesheet" type="text/css" />
	<link class="user" href="/j/a4j/s/3_3_2.SR1stylesheet/theme.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__" rel="stylesheet" type="text/css" />
	<link class="user" href="/j/stylesheet/theme.css" rel="stylesheet" type="text/css" />
	<link class="user" href="/j/stylesheet/fullcalendar.css" rel="stylesheet" type="text/css" />
	<script src="/j/js/fullcalendar.min.js" type="text/javascript"></script>
	<link class="user" href="/j/stylesheet/pf-rf-central.css" rel="stylesheet" type="text/css" />
	<link rel="shortcut icon" href="/j/favicon.ico" />
	<script type="text/javascript" src="/j/primefaces_resource/1.0.0.RC/yui/utilities/utilities.js"></script>
	<script type="text/javascript" src="/j/primefaces_resource/1.0.0.RC/primefaces/core/core.js"></script>
	<link rel="stylesheet" type="text/css" href="/j/primefaces_resource/1.0.0.RC/primefaces/layout/layout.css" />
	<script type="text/javascript" src="/j/primefaces_resource/1.0.0.RC/jquery/jquery.js"></script>
	<script type="text/javascript" src="/j/primefaces_resource/1.0.0.RC/jquery/plugins/layout/jquery.layout.min.js"></script>
	<script type="text/javascript" src="/j/primefaces_resource/1.0.0.RC/jquery/plugins/ui/jquery.ui.custom.js"></script>
	<script type="text/javascript" src="/j/primefaces_resource/1.0.0.RC/primefaces/layout/layout.js"></script>

</head>


JBoss EAP 6.4.0 | Mojarra 2.1.28 | PrimeFaces 6.2.3

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

29 Jan 2010, 15:41

Yes, it is obvioud that pf layout.css is placed after your css, I'm not familiar with a4j:loadStyle tag, it might be the reason. Where do you keep your stylesheet/pf-rf-central.css file, in webapp root? If so can you try;

Code: Select all

 <link class="user" href="#{facesContext.externalContext.requestContextPath}/stylesheet/pf-rf-central.css" rel="stylesheet" type="text/css" />
instead of a4j:loadStyle.

mbeedub
Posts: 93
Joined: 28 Jan 2010, 23:54

29 Jan 2010, 16:01

I think you're right - something to do with the phases the a4j:loadStyle and p:resources are invoked maybe? Not sure.

Anyway, you're suggestion worked so we'll go with that.

Many thanks!
JBoss EAP 6.4.0 | Mojarra 2.1.28 | PrimeFaces 6.2.3

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

29 Jan 2010, 16:18

Glad it works, if the expression seems too long,

Code: Select all

<link class="user" href="#{request.contextPath}/stylesheet/pf-rf-central.css" rel="stylesheet" type="text/css" />
could work as well.

mbeedub
Posts: 93
Joined: 28 Jan 2010, 23:54

29 Jan 2010, 16:32

Prefect. Yes that works (and a bit tidier... :D ). Thanks again Cagatay.
JBoss EAP 6.4.0 | Mojarra 2.1.28 | PrimeFaces 6.2.3

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 41 guests