- [Instructor] In order for Java to send data from the model to the controller to the view, we need to create what's called a Java bean, or a backing bean, and to do that, we need to create what's called a backing bean class or Java class to do that. So let's go ahead and create one in here. I'm going to go into the hplus.sport package here and create a new class, and we'll call it HPlusSportTeam. This is just the name of our class, and then just go ahead and click Finish.
Okay, I'm gonna remove this comment here, and just like before, we're gonna create the ManagedBean object here. So for this bean, instead of using the default, which is the name of your class, we're going to have it a different name. We'll give it a name, call it team, so when I reference this bean, I can reference it by using this name instead of the whole class name, and I also wanna set eager to true, just to make sure that it doesn't do the lazy loading. So I also wanna create the SessionScope here as well.
We'll be using SessionScope in this course, and then go ahead and import the libraries. Just mouse over these squiggly red lines and choose that library. Okay, so in here we need to create two very special objects. One of them is called the employee. This is like a shell that stores all the single employee record information, and then once we have the correct data stored in that employee record, or that object, then we need to move that over to a list of employees.
So we have two of them. So the first one I'm gonna create is called the EmployeeType, and also just call it employee with the lowercase, and then we also need the other object called a List of Employee. It's gonna be a List. I'll call this one employeeList, and I'm gonna go ahead and instantiate this object here. So it's gonna be an ArrayList, and you can put the data type in here if you want, but it's not required.
You can put Employee here if you want, but it's no longer required in this version of Java. So go ahead and import the library, which is the utility for the List, and the same for the ArrayList utility. Okay, and then also go ahead and create the setters and getters for this file. You could just mouse over here, and then click the Create setter and getter, and then click OK, and the same thing for this one here, and then we're good. Now, I want to make sure we understand what these two objects mean and why they are important.
So I'm gonna show a slide to show what this means. So here's our Employee object. This is like a shell that is temporary. We will store all the information in here, and then once we have these records, or this information, we can then move that over to the employeeList. So this is the object of employeeList. It stores all the records in here, and then, so each Employee that we create, we will pass along and store inside this list here, as you can see in this diagram, and then now we have a list of Employees, and later on, if you want to modify, edit, or delete any one of these records, we can then find their specific ID, or the index position, and then we can retrieve that by calling the employeeList.get method, and supply the index, in this case let's just say you wanna pull Employee two out.
We'll select the index one, and then that index will be pulled, and the information will be pulled out back to the Employee object, and from there on we can access the data and do whatever we want. So this is a really good concept we wanna see, and to make sure you understand how they are used in this application. So now that we understand how these two objects are related, we are ready to go ahead and then populate this object with some data.
- Setting up JSF
- JSF class creation
- Preparing lists of data
- Configuring source files
- Building UI components
- Building interface menus
- Displaying data-bound table components
- Adding, viewing, updating, and deleting data
- Displaying messages and message tags
- Validating data in a form
- Setting session attributions
- Authenticating permissions across JSF pages