1. Home
  2. Training Library
  3. Programming
  4. Programming Courses
  5. Building Web Applications with Java EE 6

JSF Employee Project Part 2

Contents

keyboard_tab

The course is part of this learning path

Start course
Difficulty
Beginner
Duration
1h 16m
Students
8
Description

This course explores the fundamentals of web applications, JavaServer Faces, and then walks you through a variety of projects that will give you a practical demonstration of how to create a web application and how to use various components of JavaServer Faces.

Learning Objectives

  • Understand the fundamentals of web applications
  • Learn about JavaServer Faces, and how they can be used in your applications

Intended Audience

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

Prerequisites

Basic knowledge of Java programming.

Transcript

Hello dear friends. In this video, we continue creating our project. Let's begin. In the last video, we have finished elements and we need a button, command button as save. With this, I want to show these values in another page. As you know, this course is about Java and I don't want to do any database operations. So, let's add new page and name EmployeeDetail. Now I will show all elements in this page. Let's define output labels one by one: Name, Username, Password, isAdmin. Go on. Done. Now turn back. In save button, only we need to direct this page. Now let's try. And look, now we can see all values. And look, our password is now clear. Now let's add two more buttons to our page. In component video, I forgot to show them. First one is command link. This is the same with label link. In action, I will redirect EmployeeDetail page. Value is the text that we will see as link name, like send the other page.

Now, let's try. Look, there is no difference between link and command. Now there is another link type as output link, but you must use this only for outsources like Twitter or Google. If you try to redirect any page in this project, this will be an error. Let's add two output link. This one is Twitter and we have to set Twitter's link in value. We will name between open and closed tags. Let's try. Let's try with Twitter, and as you can see, the Twitter. Now, let's make another page to take more than one employee. As you remember, we have learned the scoped types as session or request. Now with session scoped, we will hold all employees that we have added in this session, and then we will send it to the page. Let's begin. First, I need another button. Let's name it Redirect. Now I will use the 'Save' button to save. First, go to the ManagedBean. Let's define a list and name it Employee List.

Type will be employee. We will hold employees in this list. Generate getter and setter. Let's define a save method. In this method, we will save new value to the employee list. First, we need an instance from employee. Now we will set all elements from page. For this, we will use this keyword; name, username. Now let's add this new employee into the list. Done. Now for each save click, we will hold new employee in list. Now we need another bean to hold this list. Add new class named person. Of course, this will be a ManagedBean. Adjust session scoped. Done. Let's define a constructor. Now we can get our EmployeeBean. First, we will define an employee class. Now over of this line, we have to set the other ManagedBean with ManagedProperty. It is very easy, ManagedProperty. Now we need value. Value will be the other bean. Done. Also, we need an employee list. Generate getters and setters. Now in constructor, we will match this list with filled employees list. Done. Now we can use.

Add new page or if you want you can use old one. Now in page, we will use data table. Add a data table. Now in data table, we will define our list like in select items, var = 'list' value. Now we will set employee list. After that, we will add our columns one by one. Columns for name. For header, we can use facet command. Name, I will add them one by one. Done. Now we have finished. Let's try. Let's add an employee. Add another. Now let's go to the page. Look, we can see all necessary details of employees. We have now completed our project. We will conclude this section with this video. Actually, I want to explain how to use Ajax with JSF, but I'll do so after the Servlet topic. I'd like to demonstrate how to use Ajax with both JSF and JSP. So, we'll continue with Servlet. Facelets will be introduced in the following video. See you in the following video.

 

About the Author
Students
1230
Courses
64
Learning Paths
4

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