Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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

Arrow left icon
Profile Icon Caliskan Profile Icon Varaksin
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9 (9 Ratings)
Paperback May 2015 412 pages 1st Edition
eBook
S$36.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial
Arrow left icon
Profile Icon Caliskan Profile Icon Varaksin
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9 (9 Ratings)
Paperback May 2015 412 pages 1st Edition
eBook
S$36.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial
eBook
S$36.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781784393427
Vendor :
Apache
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

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 S$6 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 S$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total S$ 230.97
PrimeFaces Beginner's Guide
S$74.99
Mastering JavaServer Faces 2.2
S$88.99
Primefaces Cookbook Second Edition
S$66.99
Total S$ 230.97 Stars icon

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 included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.