Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Primefaces Cookbook Second Edition
Primefaces Cookbook Second Edition

Primefaces Cookbook Second Edition: Over 100 practical recipes to learn PrimeFaces 5.x – the most popular JSF component library on the planet

eBook
$9.99 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Primefaces Cookbook Second Edition

Chapter 2. Theming Concepts

In this chapter, we will cover the following topics:

  • Understanding structural and skinning CSS
  • Installing themes
  • Customizing default theme styles
  • Adjusting the font and size throughout the web application
  • Simple ways to create a new theme
  • Stateless and stateful theme switchers
  • Integrating Font Awesome with PrimeFaces

Introduction

In this chapter, readers will be introduced to PrimeFaces themes and the concepts involved. Later on, we will build on these concepts to learn theming of the PrimeFaces components. The theming concept used in PrimeFaces is similar to the jQuery ThemeRoller CSS Framework (http://jqueryui.com/themeroller). All PrimeFaces components are designed to allow a developer to integrate them seamlessly into the look and feel of an entire web application. At the time of writing, there are 38 plus ready-to-use themes, which you can preview and download from the PrimeFaces Theme Gallery (http://primefaces.org/themes). There are two kinds of themes: ELITE themes that are available to ELITE & PRO users exclusively or as a standalone purchase, and Community themes that are free to use under Apache License. Community themes include the ones available in ThemeRoller and custom themes such as Twitter Bootstrap.

Powered by ThemeRoller, PrimeFaces separates structural CSS from skinning CSS....

Understanding structural and skinning CSS

Each component is styled with CSS and contains two layers of style information—structural or component-specific and skinning or component-independent styles.

In this recipe, you will understand the difference between these two types of CSS, learn some useful selectors, and see an exemplary styling of the pickList component in the generated HTML.

Getting ready

To learn about different layers of style information, you can go to the PrimeFaces Showcase (http://primefaces.org/showcase) and look at it in the Firefox browser with an installed Firebug add-on (http://getfirebug.com). Firebug allows live editing, debugging, and monitoring CSS, HTML, and JavaScript in any web page. Another useful tool is the built-in Developer Tools for the Google Chrome browser, which is similar to the Firebug. Both these tools can be opened by pressing the F12 key.

How to do it…

Go to the PrimeFaces Showcase and choose the PickList component from the left sidebar...

Installing themes

PrimeFaces themes are bundled as JAR files. Community themes are free and available for download at the PrimeFaces repository (http://repository.primefaces.org/org/primefaces/themes). Each theme can be quickly previewed before download at PrimeFaces Theme Gallery (http://primefaces.org/themes) or tested in the PrimeFaces Showcase with an integrated theme switcher.

In this recipe, we will install and configure themes to use them in an JSF application. The steps to accomplish this task are straightforward.

Getting ready

If you are a Maven (http://maven.apache.org) user, ensure that you have Maven installed. Maven is a build and project management tool, which manages installation of all dependencies in an easy way. PrimeFaces is a Maven-based project and offers all artifacts, including themes, as Maven dependencies.

How to do it…

Maven users should define any desired theme artifact in their project's pom.xml as follows:

<dependency>
  <groupId>org.primefaces...

Customizing default theme styles

How to customize theme styles is one of the most asked questions by the PrimeFaces users. There are simple rules to be followed to overwrite bundled theme styles with custom CSS. There is no need to edit bundled themes and repackage theme JAR files.

In this recipe, we will present two examples for theme customization—one for selectOneMenu and another for the tree component. We will see how to change styles for a particular component or for all components of the same type. The reason to do that could be a company style guide with the need to maintain corporate identity throughout all applications. Furthermore, we will learn tips for customizing default styles on input components.

How to do it…

Let's set a fixed width for p:selectOneMenu and remove the background and border for p:tree. The default width of p:selectOneMenu is calculated at runtime. That means, the width of p:selectOneMenu is dynamic and depends on its content (select items)...

Adjusting the font and size throughout the web application

Each PrimeFaces theme has a specific font family and font size, which can differ from theme to theme. This may have a disadvantage in a multi-theme application because switching from one theme to another would cause a broken layout. Furthermore, default font sizes of themes might be bigger than expected. Hence, it is important to know how to change font properties of the PrimeFaces components globally.

In this recipe, we will learn how to adjust the font family and font size throughout the web application.

How to do it…

A simple way to change fonts globally can be accomplished by using the .ui-widget style class. An example of smaller font is as follows:

.ui-widget, .ui-widget .ui-widget {
  font-size: 90% !important;
}

Note

Using !important in CSS can sometimes be useful to force a rule, so that you can place your CSS in any order in HTML.

This might not be enough in some cases, especially when you mix PrimeFaces and JSF standard...

Simple ways to create a new theme

We sometimes need to create our own themes instead of using the predefined ones. Web applications should often feature a company-specific look and feel, which is constant and preset by company-wide style guides. Creating new themes is easy with PrimeFaces because it is powered by the ThemeRoller CSS Framework (http://jqueryui.com/themeroller). ThemeRoller provides a powerful and easy-to-use online visual tool.

In this recipe, we will systematically show all the required steps to create a new theme.

Getting ready

To gain first-hand experience of the ThemeRoller online visual tool, go to the ThemeRoller home page, explore the available theme's Gallery, and play with the CSS properties to see changes for jQuery widgets embedded on the page. All CSS changes will be applied on the fly.

Getting ready

How to do it…

The simplest way to make our own theme is to modify one of the existing PrimeFaces themes. Choose one from the PrimeFaces Theme Gallery (http://primefaces...

Introduction


In this chapter, readers will be introduced to PrimeFaces themes and the concepts involved. Later on, we will build on these concepts to learn theming of the PrimeFaces components. The theming concept used in PrimeFaces is similar to the jQuery ThemeRoller CSS Framework (http://jqueryui.com/themeroller). All PrimeFaces components are designed to allow a developer to integrate them seamlessly into the look and feel of an entire web application. At the time of writing, there are 38 plus ready-to-use themes, which you can preview and download from the PrimeFaces Theme Gallery (http://primefaces.org/themes). There are two kinds of themes: ELITE themes that are available to ELITE & PRO users exclusively or as a standalone purchase, and Community themes that are free to use under Apache License. Community themes include the ones available in ThemeRoller and custom themes such as Twitter Bootstrap.

Powered by ThemeRoller, PrimeFaces separates structural CSS from skinning CSS. The...

Understanding structural and skinning CSS


Each component is styled with CSS and contains two layers of style information—structural or component-specific and skinning or component-independent styles.

In this recipe, you will understand the difference between these two types of CSS, learn some useful selectors, and see an exemplary styling of the pickList component in the generated HTML.

Getting ready

To learn about different layers of style information, you can go to the PrimeFaces Showcase (http://primefaces.org/showcase) and look at it in the Firefox browser with an installed Firebug add-on (http://getfirebug.com). Firebug allows live editing, debugging, and monitoring CSS, HTML, and JavaScript in any web page. Another useful tool is the built-in Developer Tools for the Google Chrome browser, which is similar to the Firebug. Both these tools can be opened by pressing the F12 key.

How to do it…

Go to the PrimeFaces Showcase and choose the PickList component from the left sidebar (the PickList...

Left arrow icon Right arrow icon

Description

This book is for everybody who would like to learn modern Java web development based on PrimeFaces and is looking for a quick introduction to this matter. Prerequisites for this book are basic JSF, jQuery, and CSS skills.

Who is this book for?

This book is for everybody who would like to learn modern Java web development based on PrimeFaces and is looking for a quick introduction to this matter. Prerequisites for this book are basic JSF, jQuery, and CSS skills.

What you will learn

  • Understand basic concepts such as AJAX processing and partial view submit so that you can work with PrimeFaces
  • Go beyond the basics and discover more interesting features of PrimeFaces: PrimeFaces selectors, RequestContext, Dialog Framework, and more
  • Delve deep into over 100 rich UI components with all the required details
  • Get practical solutions to complex problems that arise in a JSF ecosystem
  • Use best practices, avoid pitfalls, and get performance tips when working with the component suite
Estimated delivery fee Deliver to South Korea

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 28, 2015
Length: 412 pages
Edition : 1st
Language : English
ISBN-13 : 9781784393427
Vendor :
Apache
Concepts :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to South Korea

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details

Publication date : May 28, 2015
Length: 412 pages
Edition : 1st
Language : English
ISBN-13 : 9781784393427
Vendor :
Apache
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 169.97
PrimeFaces Beginner's Guide
$54.99
Mastering JavaServer Faces 2.2
$65.99
Primefaces Cookbook Second Edition
$48.99
Total $ 169.97 Stars icon
Banner background image

Table of Contents

12 Chapters
1. Getting Started with PrimeFaces Chevron down icon Chevron up icon
2. Theming Concepts Chevron down icon Chevron up icon
3. Enhanced Inputs and Selects Chevron down icon Chevron up icon
4. Grouping Content with Panels Chevron down icon Chevron up icon
5. Data Iteration Components Chevron down icon Chevron up icon
6. Endless Menu Variations Chevron down icon Chevron up icon
7. Working with Files, Images, and Multimedia Chevron down icon Chevron up icon
8. Drag Me, Drop Me Chevron down icon Chevron up icon
9. Creating Charts and Maps Chevron down icon Chevron up icon
10. Client-side Validation Chevron down icon Chevron up icon
11. Miscellaneous Advanced Use Cases Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9
(9 Ratings)
5 star 33.3%
4 star 44.4%
3 star 11.1%
2 star 0%
1 star 11.1%
Filter icon Filter
Top Reviews

Filter reviews by




Dominik Pieper Jul 07, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The first chapter starts with how to setup PrimeFaces and the basics, how the PrimeFaces AJAX mechanism works and the internationalization configuration. The next chapter show how to configure, change and create new themes with jQuery themeroller and css. The next chapters group the PrimeFaces components into specific topics. Inputs like input fields (with and without auto completion), spinner, slider and editor components. Grouping elements with PrimeFaces grid system and panels. How to present and visualize data with tables, charts and maps. Every topic with ready to use recipes.In my opinion this book is an excellent and practical book which will help you to solve a lot of common problems.
Amazon Verified review Amazon
eduardo kremer Jun 21, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I recommend this book to anyone who is engaged (or plan to be) in implementing a JSF project and wants to take advantage of PrimeFaces' fast-paced development edge. Though PrimeFaces is a powerful library on JSF which allows you to greatly speed up your web project development compared to other technologies, it involves high abstraction so you need a good sidekick (book) in order to beat your project's challenges. In my case, I wanted to get both a grasp on PrimeFaces and also a step-by-step walk-through on how to solve some complex situations (Chapter 10 Advanced Use Cases: a MUST !!!). Chapter 5 clearly explains essentials such as: sorting, listing, and visualizing data by using data iteration components. The book's GitHub allows you to build and run its projects in a snap of finger all at once ! If you actually want to take full advantage of this book you need to have some understanding on JSF, jQuery, CSS, and HTML.
Amazon Verified review Amazon
Fuat Yazar Dec 18, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I recently started using PrimeFaces for one of my project; Although there is PrimeFaces' own showcase web site, good examples with good documentation, I knew I needed some extra background and this book provided most of all.I read almost whole book except some chapters (to be read later). And I read chapters' every detail, and guess what: I now understood some important concepts better. More than doing a copy paste from their source example, I got some important information from small details; I am sure authors have the same mindset as mine, I felt like they are answering my questions, right place right time.Of course I have some recommendations, for example: after every section there is a reference to sample source: a big paragraph, it repeats everywhere, i think there is no need. And It took some time to run the sample project; but after being able to run it: it was fine.And as a last note: I wish same authors had written another book for a full-fledged PF application from beginning to end, I am still struggling with navigation, Spring integration; and while deciding about again small details: for example: displaying error messages as a Growl, or on top of the page; etc. And maybe seeing a whole "UX" approach, maybe layouts. Thanks to the authors,
Amazon Verified review Amazon
Mannerheim Jan 07, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
It's a good book, but there's nothing really new in this book you can't get from the free online PrimeFaces showcase.
Amazon Verified review Amazon
MIGUEL CUBELLS BAEZA Jul 09, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Excellent book... much more polished than the first edition,and a real-must for any PrimeFaces developer.If you are already a PrimeFaces developer, the Chapter 11 with Advanced use cases is extremely useful.It is basically a compilation of the most frequent problems and challenges discussed in the PrimeFaces Forum,so you don't need to spend hours browsing the forum looking for solutions.I found one drawback in this second edition though...In the first edition, there was a chapter about how to extend PrimeFaces with your own components.However the second edition is missing such a chapter... which I think would still be useful, specially for PF 5.xIn any case, this is a must book for any PrimeFaces developer.Looking for the third edition, hopefully with more challenging Advance Use Cases ...!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela