The course is part of this learning path
In this course, we will learn the concepts of Java EE 7 with a focus on JavaServer Faces.
Learning Objectives
- What JavaServer Faces are
Intended Audience
- Anyone looking to get Oracle Java Certification
- Those who want to improve Java 7 EE knowledge
- Java developers
Prerequisites
- Have at least 2 years of Java development experience
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, commandButton 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 employee detail 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. 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. Now, I will use the 'Save' button to save. First, go to the managed bean. Let's define a list and name it EmployeeList, type will be Employee, we will hold employees in this list. Generate getter and setter. Let's define the save method. In this method, we will save new value to the EmployeeList. 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 managed bean. Adjust session scoped, done. Let's define a constructor. Now we can get our employee bean. First, we will define an employee class. Now over of this line, we have to set the other managed bean 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 EmployeeList. 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. Facelets will be introduced in the following video. See you in the following video.
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.