1. Home
  2. Training Library
  3. Programming
  4. Programming Courses
  5. Using Ajax for Java Web Applications

Ajax Using is JSF


What is Ajax?
Using Ajax with JSP

The course is part of this learning path

Start course

In this course, we explore Ajax and how it is used in Java web applications. We will also cover how to use Ajax with JavaServer Pages (JSP) and JavaServer Faces (JSF).

Learning Objectives

  • Understand the basics of Ajax
  • Learn how it can be used with JSP and JSF

Intended Audience

This course is intended for anyone who already has basic knowledge of Java and now wants to learn about Java EE 6.


Basic knowledge of Java programming.


Hello, dear friends. In this video, we will learn how to use Ajax with JSF. Let's begin. In the JSF lesson, we learned how to use JSF and created a little JSF project. If you have saved this project then go ahead and open it. If you want, you can start a new project but I prefer to continue with the old one. First, let's define a new JSF page. Now, in this page, let's define a form. In form, we need a label and an input. Let's give an ID to the input. Set value with bean as we created in old videos. Now, let's add an outputText. Give an ID, and we will add value after Ajax. Now, in this page, we will show enter text in the output text for each letter. Now, as I previously said using Ajax in JSF is very simple. We will use Ajax command in f tag. First, add close tag for input. Now, f:ajax. Now, there are three important properties in the Ajax.

First one is execute. We have to set the ID of the element that will trigger the Ajax action. In this state, we have to set the input element's ID. The second property is render. We have to set the ID of the element that will be changed at the end of the Ajax process. Last one is event. We have to set which Ajax event will be executed. For example: click, mouse over, change or key up. I will use click. Now that we've finished setting up Ajax, let's change the value of the output text. In output text, we have to set input's value. This will give us the input value. Done. Now our Ajax is ready. Let's try. Now, first let's write Ajax Using. As you can see, there is no change. Let's click on the 'Input.' And look, now, we have a text in output text. Now, let's change click with key up and try again. And look, for each letter, our Ajax is working and our text is changing with a new text input.

This is how Ajax is used with the JSF. I came across a few samples of using Ajax with Facelets in some resources. Since Facelets are a component of JSF, there is no distinction between JSF and them. So, I won't use Facelets as an example. With this video, we have completed the topic of Servlets. In the next video, we will start learning about web services in Java. Until the next video, take care.


About the Author
Learning Paths

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.

Covered Topics