Professional Documents
Culture Documents
(Download PDF) The Definitive Guide To JSF in Java Ee 8 Building Web Applications With Javaserver Faces Bauke Scholtz Online Ebook All Chapter PDF
(Download PDF) The Definitive Guide To JSF in Java Ee 8 Building Web Applications With Javaserver Faces Bauke Scholtz Online Ebook All Chapter PDF
(Download PDF) The Definitive Guide To JSF in Java Ee 8 Building Web Applications With Javaserver Faces Bauke Scholtz Online Ebook All Chapter PDF
https://textbookfull.com/product/building-restful-web-services-
with-java-ee-8-create-modern-restful-web-services-with-the-java-
ee-8-api-mario-leander-reimer/
https://textbookfull.com/product/practical-jsf-in-java-
ee-8-michael-muller/
https://textbookfull.com/product/beginning-ejb-in-java-
ee-8-building-applications-with-enterprise-javabeans-jonathan-
wetherbee/
https://textbookfull.com/product/the-definitive-guide-to-
adonisjs-building-node-js-applications-with-javascript-
christopher-pitt/
Pro JPA 2 in Java EE 8: An In-Depth Guide to Java
Persistence APIs - Third Edition Mike Keith
https://textbookfull.com/product/pro-jpa-2-in-java-ee-8-an-in-
depth-guide-to-java-persistence-apis-third-edition-mike-keith/
https://textbookfull.com/product/java-ee-7-development-with-
netbeans-8-1st-edition-heffelfinger-david-r/
https://textbookfull.com/product/javaserver-faces-introduction-
by-example-juneau-josh/
The Definitive
Guide to JSF in
Java EE 8
Building Web Applications with
JavaServer Faces
—
Bauke Scholtz
Arjan Tijms
The Definitive Guide to
JSF in Java EE 8
Building Web Applications with
JavaServer Faces
Bauke Scholtz
Arjan Tijms
The Definitive Guide to JSF in Java EE 8: Building Web Applications with
JavaServer Faces
Bauke Scholtz Arjan Tijms
Willemstad, Curaçao Amsterdam, Noord-Holland, The Netherlands
Chapter 1: History����������������������������������������������������������������������������������������������������� 1
In the Beginning . . .���������������������������������������������������������������������������������������������������������������������� 1
The Adolescent Years�������������������������������������������������������������������������������������������������������������������� 4
On to Maturity������������������������������������������������������������������������������������������������������������������������������� 7
Rejuvenation������������������������������������������������������������������������������������������������������������������������������� 11
v
Table of Contents
Chapter 3: Components������������������������������������������������������������������������������������������ 55
Standard HTML Components������������������������������������������������������������������������������������������������������ 58
Standard Core Tags��������������������������������������������������������������������������������������������������������������������� 62
Life Cycle������������������������������������������������������������������������������������������������������������������������������������ 65
Restore View Phase (First Phase)������������������������������������������������������������������������������������������ 66
Apply Request Values Phase (Second Phase)������������������������������������������������������������������������ 66
Process Validations Phase (Third Phase)������������������������������������������������������������������������������� 67
Update Model Values Phase (Fourth Phase)�������������������������������������������������������������������������� 68
Invoke Application Phase (Fifth Phase)���������������������������������������������������������������������������������� 68
Render Response Phase (Sixth Phase)���������������������������������������������������������������������������������� 68
Ajax Life Cycle����������������������������������������������������������������������������������������������������������������������������� 69
View Build Time�������������������������������������������������������������������������������������������������������������������������� 70
View Render Time����������������������������������������������������������������������������������������������������������������������� 71
View State����������������������������������������������������������������������������������������������������������������������������������� 72
View Scope��������������������������������������������������������������������������������������������������������������������������������� 74
Phase Events������������������������������������������������������������������������������������������������������������������������������� 75
Component System Events��������������������������������������������������������������������������������������������������������� 76
Custom Component System Events�������������������������������������������������������������������������������������������� 82
JSTL Core Tags���������������������������������������������������������������������������������������������������������������������������� 83
Manipulating the Component Tree���������������������������������������������������������������������������������������������� 89
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
Layers��������������������������������������������������������������������������������������������������������������������������������������� 314
Naming Conventions����������������������������������������������������������������������������������������������������������������� 316
ix
Table of Contents
x
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 501
xi
About the Authors
Bauke Scholtz is an Oracle Java Champion, a member
of the JSF 2.3 Expert Group, and the main creator of the
JSF helper library OmniFaces. On the Internet, he is more
commonly known as BalusC, who is among the top users
and contributors on Stack Overflow. Bauke has integrated
several OmniFaces solutions into JSF 2.3. He is a web
application specialist and consults or has consulted for
Mercury1 Limited, MyTutor, Nava Finance, LinkPizza, ZEEF,
M4N/Zanox, ITCA, RDC, and more clients from fintech,
affiliate marketing, social media, and more as part of his 17
years of experience. This book offers Bauke the opportunity
to go into depth to answer most frequently asked questions and correctly solve most
commonly encountered problems while using JSF.
Arjan Tijms works for Payara Services Ltd and is a JSF (JSR
372) and Security API (JSR 375) Expert Group member. He
is the co-creator of the popular OmniFaces library for JSF,
which was a 2015 Duke’s Choice Award winner, and is the
main creator of a set of tests for the Java EE authentication SPI
(JASPIC) used by various Java EE vendors. Arjan holds an MSc
degree in Computer Science from the University of Leiden,
The Netherlands. Writing about this topic was a natural
choice for Arjan; He has already written much about it on his
blog and wanted to expand that by contributing to a book.
xiii
About the Technical Reviewer
Chád (“Shod”) Darby is an author, instructor, and speaker
in the Java development world. As a recognized authority
on Java applications and architectures, he has presented
technical sessions at software development conferences
worldwide (in the United States, UK, India, Russia, and
Australia). In his 15 years as a professional software architect,
he’s had the opportunity to work for Blue Cross/Blue Shield,
Merck, Boeing, Red Hat, and a handful of startup companies.
Chád is a contributing author to several Java books,
including Professional Java E-Commerce (Wrox Press),
Beginning Java Networking (Wrox Press), and XML and
Web Services Unleashed (Sams Publishing). Chád has Java certifications from Sun
Microsystems and IBM. He holds a BS in computer science from Carnegie Mellon
University. You can visit Chád’s blog at www.luv2code.com to view his free video tutorials
on Java. You can also follow him on Twitter at @darbyluvs2code.
xv
CHAPTER 1
History
This chapter describes the history of JSF, starting from its early conception and ending
where we are today at the moment of writing. We’ll discuss how the JSF API (application
programming interface) itself evolved, which important events took place during that
evolution, and who some of the people were that were involved in all of this.
This is in no way a complete description of the history and the reader should
take notice of the fact that many more events took place and many more people were
involved than we were able to mention here.
This JSR conflicts with the Apache open source project Struts. Considering
Sun’s current position that JSRs may not be independently implemented
under an open source license, we see little value in recreating a technology
in a closed environment that is already available in an open environment.
1
© Bauke Scholtz, Arjan Tijms 2018
B. Scholtz and A. Tijms, The Definitive Guide to JSF in Java EE 8, https://doi.org/10.1007/978-1-4842-3387-0_1
Chapter 1 History
To the extent that this JSR extends beyond Struts today, we would encourage
the Sun developers proposing this JSR to join the Sun developers already
leading Struts to create an open solution at Apache, something which when
finished would be assured of being able to be implemented as open source.
Eventually the conflict was resolved when after about a year into the process spec
lead Amy Fowler (from Swing fame) was replaced by Craig McClanahan, the very
father of the Struts project that JSF was said to be competing with. The open source
restriction was lifted as well, and the open source JSF implementation, called MyFaces,
was developed in parallel with the (then nameless) RI and hence the specification itself.
MyFaces initially started as an LGPL licensed project at sourceforge.net in December
2002 and had an initial 0.1 release conforming to what was then called an “Early Access
Specification” in January 2003.
Open source implementations are the most common implementations in Java
EE 8, and there’s barely any EE specification at the time of this writing (2018) that’s still
implemented as closed source. In 2001, however, this was not just uncommon; it was
actually not allowed for new JSRs. Allowing for an open source implementation was
therefore quite a change, and the honor fell to JSF to be the first of its kind for which this
was allowed.
Despite the open source implementation being allowed, the actual development of
the spec was still done in secret and behind closed doors. There was no public mailing
list, and no tracker (e.g., a JIRA instance) for the public to create issues or express wishes.
Occasionally interviews were being done, and in the fall of 2002 by then former spec lead
Amy Fowler did reveal quite a few details about JSF, but largely the project was shrouded
in mystery for the general public.
The team behind JSF was, however, hard at work. The first e-mail to the internal
JSR-127 list was sent on August 17, 2001. As with most projects, the team spent the initial
months on gathering requirements and looking at the existing competing products. A
package name was chosen as well. The initial placeholder package, which was "javax.
servlet.ui", now "javax.faces", was chosen as the package to use. The very first
technical architecture to be considered was the component model. For a component-
based MVC framework this is obviously one of the most important aspects. During the
last month of 2001 and the first two months of 2002 the team looked at what is now known
as the Managed Bean (called “Object Manager” then). Managed beans with their scopes,
names, and dependency injection are clearly another cornerstone of the JSF framework.
Events and the model behind it were being looked at as well during that time frame.
2
Chapter 1 History
In the second quarter of 2002 two other cornerstones of JSF were discussed: the
Expression Language (inspired by JSTL), which is instrumental for the so-called bindings
of beans from a template to backing code, and the factory finder, which allowed key
parts of JSF to be replaced and although perhaps not fully realized at the time may have
contributed greatly to JSF still being relevant some 16 years later.
It was in this same quarter that Craig McClanahan took over as spec lead, father of
Struts and architect of Tomcat’s Servlet container, took over. Not long after the discussion
about using JSP started, a discussion, perhaps unbeknownst to the team at the time, that
would, unfortunately, have a rather negative impact on JSF later on. Around the end
of the year 2002, Ed Burns, who like McClanahan had also worked on Tomcat before,
joined the team as co-spec lead. Burns is the person who would eventually become the
main spec lead of JSF for well over a decade.
While the team continued to work on things like the aforementioned managed
beans and the so-called value binding, which is the Java representation of the also
aforementioned expression language binding, the first dark cloud appeared when in the
spring of 2003 team member Hans Bergsten realized that there were very real and major
issues with using JSP as the templating language for JSF. He brought these concerns to
the team, but ultimately they weren’t addressed and instead the following months were
spent, among other things, on a variant of the value binding; it later on became clear that
the method binding and the state saving mechanism were another of JSF’s less than ideal
implementations.
JSF 1.0 and its still nameless RI were eventually released on March 11, 2004—
coincidentally, a mere two weeks before the release of another framework that’s still
strong today, Spring 1.0. MyFaces released its 1.0.0 alpha version only days later, on
March 19. It’s perhaps an interesting observation that JSF went final with a full-fledged
XML-based dependency injection (DI) framework just before Spring, which is largely
known for its DI, went final.
JSF 1.0 was generally well received; despite a rather crowded market with
competitors such as Tapestry, WebObjects, Velocity, and Cocoon operating, not less than
three books from writers such as Horst Caymann and Hans Bergsten appeared in the
months after, and the eXo platform (a Digital Collaboration Platform) started using JSF
right away.
Hans Bergsten’s earlier concerns, however, become painfully clear almost just
as quickly; the JSP technology is based on processing a template from start to end,
immediately writing to the response as tags are encountered. JSF, however, requires
a phased approach where components need to be able to inspect and act on the
3
Chapter 1 History
component tree, which is built from the tags on the page, before starting to write
anything to the response. This mismatch led to many strange issues, such as content
disappearing or being rendered out of order.
Only three months after the introduction of JSF, Hans Bergsten made a strong case
of dropping JSP in his legendary article “Improving JSF by Dumping JSP.” There Bergsten
explains how ill-suited JSP is for use a template language in JSF, but he also presents
a glimmer of hope; because of JSF’s great support for extendibility, it’s relatively easy
to introduce alternative templating simply by replacing the so-called view handler,
something which JSF explicitly allows. It would, however, take five long years until JSF
would indeed ship with a more suitable view templating language, and even though JSP
had been essentially deprecated at that point it’s still present in JSF at the time of writing.
4
Chapter 2 From Zero to Hello World
• Java ➤ Installed JREs must be set to the JDK, not to the JRE. This
setting will normally also be used to execute the integrated
application server which usually requires the JDK.
1
h ttps://en.wikipedia.org/wiki/Mojibake.
2
http://tools.jboss.org/features/cdi.html.
17
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Divots
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Title: Divots
Author: P. G. Wodehouse
Language: English
NEW YORK
GEORGE H. DORAN
COMPANY
COPYRIGHT, 1923, 1924, 1925, 1926 AND 1927,
BY P. G. WODEHOUSE
DIVOTS
—B—
PRINTED IN THE UNITED STATES OF AMERICA
TO
My Daughter
LEONORA
WITHOUT WHOSE NEVER-FAILING
SYMPATHY AND ENCOURAGEMENT
THIS BOOK
WOULD HAVE BEEN FINISHED
IN
HALF THE TIME
PREFACE
Before leading the reader out on to this little nine-hole course, I
should like to say a few words on the club-house steps with regard to
the criticisms of my earlier book of Golf stories, The Clicking of
Cuthbert. In the first place, I noticed with regret a disposition on the
part of certain writers to speak of Golf as a trivial theme, unworthy of
the pen of a thinker. In connection with this, I can only say that right
through the ages the mightiest brains have occupied themselves
with this noble sport, and that I err, therefore, if I do err, in excellent
company.
Apart from the works of such men as James Braid, John Henry
Taylor and Horace Hutchinson, we find Publius Syrius not disdaining
to give advice on the back-swing (“He gets through too late who
goes too fast”); Diogenes describing the emotions of a cheery player
at the water-hole (“Be of good cheer. I see land”); and Doctor Watts,
who, watching one of his drives from the tee, jotted down the
following couplet on the back of his score-card:
One final word. The thoughtful reader, comparing this book with
The Clicking of Cuthbert, will, no doubt, be struck by the poignant
depth of feeling which pervades the present volume like the scent of
muddy shoes in a locker-room: and it may be that he will conclude
that, like so many English writers, I have fallen under the spell of the
great Russians.
This is not the case. While it is, of course, true that my style owes
much to Dostoievsky, the heart-wringing qualities of such stories as
“The Awakening of Rollo Podmarsh” and “Keeping in with Vosper” is
due entirely to the fact that I have spent much time recently playing
on the National Links at Southampton, Long Island, U.S.A. These
links were constructed by an exiled Scot who conceived the dreadful
idea of assembling on one course all the really foul holes in Great
Britain. It cannot but leave its mark on a man when, after struggling
through the Sahara at Sandwich and the Alps at Prestwick, he finds
himself faced by the Station-Master’s Garden hole at St. Andrew’s
and knows that the Redan and the Eden are just round the corner.
When you turn in a medal score of a hundred and eight on two
successive days, you get to know something about Life.
And yet it may be that there are a few gleams of sunshine in the
book. If so, it is attributable to the fact that some of it was written
before I went to Southampton and immediately after I had won my
first and only trophy—an umbrella in a hotel tournament at Aiken,
South Carolina, where, playing to a handicap of sixteen, I went
through a field consisting of some of the fattest retired businessmen
in America like a devouring flame. If we lose the Walker Cup this
year, let England remember that.
P. G. WODEHOUSE
The Sixth Bunker
Addington
CONTENTS
CHAPTER PAGE
I THE HEART OF A GOOF 15
II HIGH STAKES 51
III KEEPING IN WITH VOSPER 85
IV CHESTER FORGETS HIMSELF 116
V THE MAGIC PLUS FOURS 153
VI THE AWAKENING OF ROLLO PODMARSH 183
VII RODNEY FAILS TO QUALIFY 210
VIII JANE GETS OFF THE FAIRWAY 246
IX THE PURIFICATION OF RODNEY SPELVIN 283
DIVOTS
CHAPTER I
THE HEART OF A GOOF