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
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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

Billing Address

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

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 : 9781784396831
Vendor :
Apache
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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

Billing Address

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.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
€189.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
€264.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 128.97
PrimeFaces Beginner's Guide
€41.99
Mastering JavaServer Faces 2.2
€49.99
Primefaces Cookbook Second Edition
€36.99
Total 128.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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.