image
JSF Employee Project part 1

The course is part of this learning path

Start course
Difficulty
Intermediate
Duration
1h 9m
Students
22
Ratings
5/5
starstarstarstarstar
Description

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 
Transcript

Hello dear friends. In this video, we will make a little project with JSF. Let's begin. Now, in the previous video, we have learned the usage of form elements in JSF. Now let's make a little employee detail page with JSF. First, create a new project. I will create new project quickly. Name will be EmployeeDetail. First, add an index page with XHTML. Done. We will start with managed bean. Add new class name will be Employee. Now we will define properties. We need name surname as string. Copy for user name. For dropdown, I will add country. This will be string. For hobbies, we will define a list because we will have more than one hobby. Password; we will use this with input secret. For one checkbox, add isAdmin. Add position. We will use this with one radio. For number input, we will define age. Now I think that's enough. Let's generate getters and setters. In source menu, generate getters and setters. Select all. Done. Now we can design our pages. Start with head and body. Now we need a form. To better view, I will use panel grid with three columns. Now we can start. Output text or output label for name. Add an input. Value will be name. Now we will set an ID as name. This will be required. I will define required message also. Let's define message tag. Message color will be blue. Actually, if you want, let's define a CSS and using class. Style. Color blue. Now we can use this class in any message. Done. Another output and input for a surname. Adjust ID required and message. Another output and input for username. Add an output and input secret for password. Add an output label and select one checkbox for isAdmin. Add an output text and input for age. Now, our type is integer. Let's add a one radio for gender. Set ID and value. In each component, I will add required. Add genders with select list item. Item label. Value will be male. Add female. Let's add another one radio for position. Add positions like gender. Add a select one menu for countries. Actually, let's add countries with a hash map. First, open employee managed bean. We will add a hash map with string object parameters named countries. Now, let's add some countries. This will be enough for us. And getter and setter. Turn back JSF page. Now, we will add a select items. This tag works like a loop, so we will define our data. Var country. Now we will set our item label and item value. ItemLabel = country.key. Item value will be country.value. This will be enough for us. If you want, let's take a look. And as you can see, our countries are here. Let's go on. Let's define hobbies. First, define a list, generate getter and setter. Now, add hobbies in the hobbies list. Now turn back to the JSF page, this will be same with countries. Add selectItems, var = "hobby". Done. Let's look at the result. Run. And as you can see, there are no differences between HashMap and List. Done. Now, let's take a break here. In the next video, we will continue creating our project. See you in the next video.

About the Author
Students
2831
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