Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PrimeFaces Cookbook

You're reading from   PrimeFaces Cookbook Here are over 100 recipes for PrimeFaces, the ultimate JSF framework. It's a great practical introduction to leading-edge Java web development, taking you from the basics right through to writing custom components.

Arrow left icon
Product type Paperback
Published in Jan 2013
Publisher Packt
ISBN-13 9781849519281
Length 328 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Mert Caliskan Mert Caliskan
Author Profile Icon Mert Caliskan
Mert Caliskan
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

PrimeFaces Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with PrimeFaces FREE CHAPTER 2. Theming Concept 3. Enhanced Inputs and Selects 4. Grouping Content with Panels 5. Data Iteration Components 6. Endless Menu Variations 7. Working with Files and Images 8. Drag Me, Drop Me 9. Creating Charts and Maps 10. Miscellaneous, Advanced Use Cases Index

Improved resource ordering


PrimeFaces 3.x provides improved resource ordering to support customization. This ability could be used when Internet Explorer demands special meta tags that are expected to be placed at first or for scenarios where styling for PrimeFaces components needs to be overridden by custom styling.

Getting ready

Make sure you have at least the 3.x version of PrimeFaces in your classpath.

How to do it...

Just define <h:head> by using facet definitions where necessary.

<h:head title="PrimeFaces Cookbook - ShowCase">
<f:facet name="first">
</f:facet>
...
<f:facet name="middle">
</f:facet>
...
<f:facet name="last">
</f:facet>
...
</h:head>

Note

The <h:head> tag is used by the JSF components for adding their resources into pages, thus it's a must-have tag throughout your JSF-based applications. One of the commonly made mistakes among developers is to forget putting in the head tag.

For instance, if a stylesheet gets declared in multiple CSS files, which would be linked in the middle and last facet respectively, the stylesheet definition referred to in the middle facet will be overridden by the one defined in the last facet.

How it works...

With PrimeFaces' own HeadRenderer implementation, the resources are handled in the following order:

  1. First facet, if defined

  2. PF-JSF registered CSS

  3. Theme CSS

  4. Middle facet, if defined

  5. PF-JSF registered JS

  6. Head content

  7. Last facet, if defined

There's more...

Internet Explorer introduced a special tag named meta, which can be used as <meta http-equiv="X-UA-Compatible" content="..." />. The content of the X-UA-Compatible <meta> tag helps to control document compatibility such as specifying the rendering engine. For example, inserting the following statement into the head of a document would force IE 8 to render the page using the new standards mode:

<meta http-equiv="X-UA-Compatible" content="IE=8" />

X-UA-Compatible must be the first child of the head component. Internet Explorer won't accept this <meta> tag if it's placed after the <link> or <script> tag. Therefore, it needs to be placed within the first facet. This is a good demonstration of the resource ordering with the usage of the first facet.

PrimeFaces Cookbook Showcase application

This recipe is available in the PrimeFaces Cookbook Showcase application on GitHub at https://github.com/ova2/primefaces-cookbook. You can find the details there for running the project. When the server is running, the showcase for the improved resource ordering is available at http://localhost:8080/primefaces-cookbook/views/chapter1/resourceOrdering.jsf.

You have been reading a chapter from
PrimeFaces Cookbook
Published in: Jan 2013
Publisher: Packt
ISBN-13: 9781849519281
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime