Chad: Hi, this is Chad Darby with luv2code.com.
Welcome back to my tutorial on JavaServer Faces.
In this video, I'll give you an overview of JSF.
We'll cover the following topics.
First, we'll start off with what is JavaServer Faces.
Then we'll discuss the Model-View-Controller Design Pattern.
Next, we'll discuss the benefits of JSF,
as far as why we'd like to use it.
Then we'll take a look at some
third-party JSF UI components.
And finally, we'll wrap up with some JSF resources.
All right, so we have a lot to cover.
Let's go ahead and get started.
So what is JavaServer Faces?
Well, it's basically a framework
for building web applications in Java.
So there are a number of ways of building web apps.
You can go old school and build apps
using just plain servlets and JSPs,
or you can make use of a framework.
Now granted, there's a lot of frameworks out there like
Struts, Spring MVC and so on, however JavaServer Faces,
or JSF, is the standard web application framework
for the Java Enterprise Edition.
This is key, it's a standard, so it's
officially blessed by Oracle, as far as having
a specification for building web applications, using Java.
Also, a nice benefit here, with JSF,
is that it's a very popular framework,
so a lot of Java shops use it for building web applications.
Also, it's commonly requested,
by hiring companies or hiring managers,
that a developer should have experience with JSF.
So it's always good to get this bullet on your resume,
and also added to your skillset.
Also, a really nice thing about JSF is that
it follows some of the industry patterns, or standards.
JSF is actually based on the
Model-View-Controller design pattern.
A lot of the big web app frameworks, out there today,
make use of this Model-View-Controller design pattern.
For example, Spring MVC, ASP.NET has an MVC framework,
so a lot of frameworks make use of this pattern.
The really nice thing about it is that once you learn JSF,
and you learn this Model-View-Controller design pattern,
if you have to move over to another framework,
like Spring MVC, then you can take these concepts
and that'll help you transfer and get up to speed
on that new framework.
So it's very useful.
Here's a nice diagram of the Model-View-Controller.
With the Model-View-Controller you basically
take some key functionality of the application
and you break it up into smaller components.
Here we have a web browser, that the user will use.
They'll hit a link or submit some form data.
It'll come into the controller.
The purpose of the controller is that
it'll figure out which piece of code
needs to execute, based on the web request.
It may need to route the code to submitting form data,
or maybe querying a database, or maybe sending an email.
So the controller's like the traffic cop.
They'll determine what piece of code
needs to execute for a given web request.
Now, this controller may also access the model.
The model basically provides access
to any backend data that you may have.
The model may make a call to a backend database,
like MySQL Oracle.
Or it may even make calls out to a web service, or whatever.
The model basically handles retrieving
or updating data for you, from your backend service.
And once it has the data from the model,
then the controller will pass this data over to the view.
The view is basically a page for rendering HTML.
This may be a page that'll render the results
of a SQL query, or it could be rendering
the results of a database insert.
And that view page, effectively, at the end,
comes back as HTML and goes back to the web browser.
That's the idea of the Model-View-Controller.
Again, controller routes the request.
Model provides access to backend data.
And the view renders a view, or HTML response.
And that's the Model-View-Controller, in a nutshell.
So what are the benefits of using JSF?
I mean, why would you wanna use it?
Well again, like I mentioned earlier,
it's a standard way of building web app UIs in Java.
So for building web applications with Java,
it's part of the standard Java EE, Enterprise Edition.
Also, the JavaServer Faces framework includes
a large number of UI components.
So basically they provide nice custom tags
that allow you to generate tables,
HTML list, or any type of HTML form.
Pretty much all your UI widgets are available with JSF.
And also a really nice thing too,
and I'll talk about this in a second,
is that it's extendable.
So you can have third-part teams create UI components
that you can add to your application.
Also, another benefit of JSF is that it helps you
to manage your application state for web requests.
So when you submit form data across,
it may be only for one web request,
but you can also envision a scenario
where you wanna have your application
keep track of the form data.
So, if you're building a shopping cart application,
you may wanna keep track of the items
that the user added to their shopping cart.
Or say for example, you're building an online exam
and you wanna keep track of the answers
that the user gave for each question.
Say for example, your online exam is ten questions
and at the end you'd like to give them a pass/fail score.
Well again, you need to manage that application state.
You can make use of that using JSF.
And then finally, the most common thing
that you'll use with JSF is processing form data.
So the user will insert some data, submit it.
Here you can use JSF to perform some validation.
They have some built in validation rules.
And also you can convert the data
to different formats, based on your requirements.
This is just a very high level list
of JSF benefits, but a lot of good things.
And again, it's a very popular framework.
And also, like I mentioned a little earlier,
you can make use of the core UI components,
provided by JSF, but then there's also
a large group of developers who've created
additional UI components.
You can actually take these third-party components,
that are created by these open source developers,
and you can include them into your application.
This is a very nice bonus.
So you get the basic UI components
plus you can add in other groups.
On the screen here I've listed
three of the most popular third party UI components.
They have their own separate website.
They have their own separate file,
you download it and include it into your project,
but it's very nice.
Here, openfaces.org, primefaces.org, and RichFaces.
And these are all great sites.
They have documentation available.
And they also have demos available.
All right, so the next slide here is on JSF resources.
The official website for JSF is located here on this link.
This is a site that's hosted by Oracle.
It contains tutorials, documentation, articles and so on.
This is always a good place to start
when you're doing work with JSF, just so
you can see the official documentation,
list of methods, so on and so forth.
Also a nice thing about JSF,
since it's a popular technology,
is that there's a lot of information online about it.
So you can find a lot of free tutorials online,
simply just by doing a Google search.
You can also go to Amazon and search for books on JSF.
And there's plenty of books out here,
so here's a little screenshot of me going to
the Amazon site and typing in JavaServer Faces
and it came up with x number of books.
So there's a lot of good books out there.
One thing I wanna caution you is that,
make sure you find a recent book that's up to date.
At the time of this video,
the current version of JSF is JSF 2.2.
So make sure you find a book that's based on 2.2.
And in the screenshot here, these folks are up to date.
Or something close, like maybe 2.1 or 2.0.
But you wanna stay away from the really old books,
like JSF 1, because there's been
a lot of changes between there.
So again, try and stay with books,
here, with JS 2.2 or higher.
All right, well that pretty much wraps up the video.
What we did was we got an overview
of the JavaServer Faces framework.
We also discussed the idea
of the Model-View-Controller design pattern.
We looked at some of the benefits of JSF.
And also we had a quick demo
of the third-party JSF UI components.
And finally we wrapped up with JSF resources,
as far as Oracle's website
and also books available on Amazon.