BreadcrumbsHome / JSF Tutorial #9: JavaServer Faces Tutorial (JSF 2.2) – JSF Behind the Scenes
JSF Tutorial #9: JavaServer Faces Tutorial (JSF 2.2) – JSF Behind the Scenes
Last Updated on Sunday, 17 May 2015 Written by Chad Darby Monday, 25 May 2015
In this video, I will give you a behind the scenes tour of JSF.
Please SUBSCRIBE to my YouTube channel.
Do You Need More Details?
- Do you need to connect to a database?
- Display SQL results in a HTML table?
- Perform SQL insert, updates and deletes?
- Database Integration with JDBC
- Displaying Data in Lists and Tables
- Validating HTML Forms
- Implementing Business Logic with Managed Beans
- Deploying applications with WAR Files
Follow luv2code with the links below:
JSF Tutorial Transcript:
Hey. Welcome back. In this video we’re going to get a behind the scenes tour of JSF. We’ll cover the following topics. First off, we’ll take a look at the components of a JSF application. Then we’ll take a sneak peak behind the scenes to see how JSF actually works. Next we’ll discuss the various JSF versions that are out there. Finally, we’ll discuss application support for JSF. We have a lot of stuff in store. Let’s go ahead and get started.
What makes up a JSF application as far as what’s required to build a JSF application? A JSF application is basically a set of webpages to lay out components. We’ll make use of special JSF technology called Facelets. Then also, a JSF application is composed of a set of managed beans. This is Java code that you’ll have in the background for holding your form data and also performing your back end operations like talking to a database.
Then also there’s an idea of the web deployment descriptor or your web.xml. If you’ve done some web development before with Java, you may have seen this file before for servlets and JSPs. We’ll basically put a special configuration in that file to handle the JSF requests. Then optionally you can have some additional application config files like to faces-config.xml. You can drop in some custom objects, components, custom tags, and validators. We’ll talk about all that stuff later, but at a very high level these are the actual components of a JSF application.
How does JSF work behind the scenes? We have a user over here. They’re in their browser. They’ll submit a request to our application server. This will come into our JSF Faces Servlet. This Faces Servlet is part of the JSF library. You the developer, you don’t have to write this servlet; it’s given to you. This Faces Servlet handles routing the request to the appropriate pages. Now this Faces Servlet in the background, it can read information from the faces-config file. It can also make use of managed beans. These managed beans are basically just beans that hold form data or talk to your back end processes, like maybe a database or something.
This Faces Servlet, it will determine which page that it needs to route to. It will route it to that appropriate webpage. I’m at the bottom here. We have xhtml. This webpage can make use of the managed beans also to maybe retrieve information or display information from the back end system. This webpage is rendered and sent back to the web browser. This webpage, it could have very basic information like “Hey, welcome,” and give the user’s name, or this webpage could be more sophisticated where it would display the results of a database query. Anyway, that’s how JSF works at a very high level. Again, web browser makes the request of the servlet. Servlet will route it to the appropriate page, and the page renders the response.
Let’s talk about the different versions of JSF. There’s a lot of different versions that are floating out there, so if you google for some JSF tutorials you may find some outdated information, so I just wanted to lay out the versions and then talk about JSF 2.2.
JSF has been around for a long time. JSF 1.0 was released in 2004; that’s ancient days. Then it was JSF 1.2 that came out in 2006. JSF 2.0 came out in 2009. That was aligned up with Java EE 6. Then most recently it’s JSF 2.2; that was released in 2013. That is Java EE 7. When you look for different information like books and so on, you want to make sure that you’re using at least JSF 2.2 because there was some significant changes between 2.2 and all the previous versions. Now you also want to make sure that you have an application server that can support JSF 2.2. You want to make sure your app server has support for Java EE 7 or higher.
Now there’s a new version of JSF that’s coming out. I’ve been checking the different blog posts and so on. JSF 2.3 is slated to come out late 2016, early 2017. You can think it will hit mainstream around the 2017 time frame. Just a little indicator there. You can always go online and Google and you can simply say “JSF release date,” and you should get the latest hits as far as news reports on when JSF is coming out. Anyway, this course will focus on JSF 2.2.
In terms of application server support, if you make use of a full Java EE 7 server, then the JSF 2.2 libraries are already included. When I say a Java EE 7 server, some examples included Jboss Wildfly 8, GlassFish 4, and so on. For your given app server you want to make sure that it supports Java EE 7 or higher. Not all of the servers are up to date so you want to make sure you look at the actual specs for your server accordingly. I know out of the box that Wildfly 8 and GlassFish 4 already have full support for Java EE 7. That includes the JSF 2.2 libraries. The key thing here is that when you deploy your JSF application, there’s no need to include the JSF jar files in your app. It’s already part of those given server environments.
Now if you want to deploy with Tomcat 8 you can still do that. The only thing is that you simply need to add the JSF libraries, preferably JSF 2.2 or higher. That means that you need to bundle the JSF libraries in your war file application. In your web-inf/lib directory you’ll need to include those jar files. I’ll show you how to do this in the next video when we build our “Hello World!” application. Don’t worry if you don’t totally understand all of this. I’ll walk through the steps when we go through our “Hello World!” app and show you which checkbox that you need to set up in the Eclipse environments for getting this working. Anyway, that’s the big thing there.
This wraps up the video. We covered some good items in this video. We discussed the components of a JSF application. We also learned how JSF works behind the scenes. I also gave you a discussion of the various JSF versions that are out there. Finally, we wrapped up by discussing application server support for JSF. Stay tuned. In the next video we’ll actually get our hands dirty. We’ll build a “Hello World!” app with JSF and then we’ll actually deploy to our application server. See you then.