Upgrade a project to JSF 2.3

From the course: Java EE 8: JavaServer Faces JSF 2.3

Start my 1-month free trial
  • Course details

    The Java EE specification is the industry standard for building enterprise-level web applications. In this course, instructor Tayo Koleoso focuses on JavaServer Faces (JSF) 2.3 and shows Java programmers all of the most significant new features in the popular web application development framework. Get an introduction to the new WebSockets feature in JSF, and how to use it to supercharge your web app. Discover how to work with the latest DateTime components, leverage the new backing bean improvements, configure web application security using the new Java EE 8 security annotations, and more.


    • Click here to view Tayo Koleoso’s instructor page

      Tayo Koleoso

      Software Engineering Lead at Ntrepid LLC

      • Tayo Koleoso is a lead programmer who specializes in Java enterprise application development.

        Tayo is a Java Enterprise Edition (EE) enthusiast. He also boasts expertise in Spring, Drupal, and JavaServer Faces (JSF), the latter of which he's been a fan of since the Java specification's early days. He enjoys sharing both his JSF and PrimeFaces expertise with other developers on Stack Overflow, where he is top-10 ranked for both Java EE and JSF answers.

    Skills covered in this course

  • JavaServer Faces 2.3

    - [Instructor] First things first, I'll show you how to retrofit your existing JSF application to version 2.3. Matter of fact, you can apply the methods I'm going to demonstrate here to brand new JSF applications because not a IDEs come catered for JSF 2.3. Neither Eclipse, nor NetBeans. Not in VS code either. Not even IntelliJ comes fully sorted for JSF 2.3. You're in complete control here. As for prerequisites, you need to have an application server that implements Java EE8. That's what ships JSF 2.3. I'm talking about GlassFish version 5 or Payara version 5. For the Apache Tomcat crowd, your better off running JSF 2.3 in Tomcat 9. At the end of the day, you want to use the most recent distribution of your most beloved app server or container. Otherwise, for older servers, you'll need to manually install the necessary dependencies. Now, on to the good part. I'm going to show you how to do the upgrade using the exercise project that I built from the introduction to JSF course. But that doesn't mean anything really. Any existing JSF 2 project can be upgraded to JSF 2.3 using this same procedure. This introduction to JSF course was built on JSF 2.2 and was deployed on GlassFish 4. We begin by changing the Java EE web API version in the pom.xml. So I'm going to open the pom.xml up here, scroll over here to line 21, and change it to version 8. Save that. Then, depending on how you've set up your own specific project, you might need to modify the endorsed directory configuration. Now, I won't go into details on what the endorsed directory mechanism is specifically. Suffice it to say that Java EE8 doesn't have the same endorsed directory config as Java EE7. Scrolling down here to the maven-dependency-plugin, I'm going to remove everything from line 48 all the way to line 72. Got it, this way. It's done. I'm going to save that. Now, keep everything else the same for now. We've only just specified that we want to use Java EE8 and therefore JSF 2.3. Next, I'm going to go to the web.xml file. And you do the same if you have one. Open up here, source, main, web-app, WEB-INF, web.xml. Let's open that up and go to the source view. Here we're going to change the web-app version numbers to version 4.0. This is the latest version of the servlet specification. Go over here, change that to 4.0. Scroll over to the right a little bit and do the same here. I'm going to change this to web-app 4 and 0. Let's save that. What I've done is here enable servlet 4.0 for this web application. Now, there's also some upgrade configuration for the faces-config.xml file. So if you use one, let's see what that looks like. So let's open up this faces-config file that I have pre-created. Eclipse gives us a nice GUI to have to modify pieces of it. I'm going to go straight to source, here's what you need to do. You need to just change the version attribute here to 2.3 as well as the schema location to 2_3. This is the definitive switch to JSF 2.3 for any given web application that uses a faces-config.xml file. If your web app uses a bean.xml for enabling CDI, and I'm willing to bet that it does, or strongly recommend that you add it, you should switch that up to version 2.0 like this. I'm going to open up the beans.xml file from the Intro to JSF project. Here we have it, beans.xml is currently configured for version 1.0. So I'm going to change this here to beans 2_0, Add a version attribute here to read 2.0 as well. And that's it. We can save and deploy what we have so far. And we have a functional JSF 2.3 application. While what I've shown here was upgrading an existing application to JSF 2.3 and Java EE8 standards, you can rest assured it works for brand new web-apps also. Just follow the same steps in your favorite IDE to start a Maven web application and make the same changes I've shown here. Now, having shown you how to upgrade an existing application, you should bear in mind the same steps are applicable to a brand new application. So I have created here a brand new web application project, also Maven-based with exactly the same pieces. We can see in here it has the same web.xml with the 4.0 set as the servlet version. We have a faces-config file here, also with the version set to 2.3. We have the same beans.xml file set to 2.0.

  • Practice while you learn with exercise files

    Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.

    Download the exercise files for this course. Get started with a free trial today.

  • Download courses and learn on the go

    Watch courses on your mobile device without an internet connection. Download courses using your iOS or Android LinkedIn Learning app.

    Watch this course anytime, anywhere. Get started with a free trial today.