9.7.1 Create a Web-Based Client Project WebClientFaculty _ Select
Perform the following steps to create a new Web application project, WebClient Faculty _ Select:
1) Launch NetBeans IDE 12.0 and go to File > New Project to open the New Project wizard. Expand the Java with Ant folder and select Java Web from the Categories list and Web Application from the Projects list. Click theNext button to go to the next wizard.
2) Enter WebClientFaculty _ Select into the Project Name field as this new proj-ect’s name. Select a desired folder, such as C:\Class DB Projects\Chapter 9, to save this project in the Project Location field, and click on the Next button.
3) In the opened Server and Settings wizard, make sure that GlassFish Server has been selected as the Web server for this Web application and Java EE 7 Web ver-sion has been also selected for this project. Click on the Next button to continue.
4) In the next wizard, Frameworks, just click on the Finish button to complete the new Web application creation process.
Since we need a Faculty page as a view to query data from the Faculty Table in our sample database, we need to add the Faculty.jsp and FacultyProcess.jsp files we built in the proj-ect JavaWebOracleSelect in Chapter 8 into our current project. Perform the following opera-tions to complete the Web page addition process:
1) Open the NetBeans IDE 12.0 and the project JavaWebOracleSelect that is located in the Class DB Projects\Chapter 8 folder in the Students folder on the CRC Press ftp site, and copy two files, Faculty.jsp and FacultyProcess.jsp, from the Web Pages folder.
2) Open our new project, WebClientFaculty _ Select, and paste the two copied files from step 1 into the folder Web Pages under our new project, WebClientFaculty _ Select.
Next we need to create a Java managed bean class, FacultyMBean.java, copy the code from the managed bean FacultyQuery.java we built in the Web application project JavaWebOracleSelect and paste it into our managed bean class FacultyMBean.java in our Web-based client project.
9.7.2 Create a Java Managed Bean Class, FacultyMBean
Perform the following operations to create the Java managed bean in our current project:
1) Right-click our Web-based client project, WebClientFaculty _ Select, in the Projects window and select New > Java Class item to open the New Java Class wizard.
2) In the opened wizard, enter FacultyMBean into the Class Name field and enter web-client into the Package field.
3) Then click on the Finish button to complete the Java managed bean creation process.
4) Double-click on our new created managed bean, FacultyMBean.java, to open its code window.
5) Now open the Web application project JavaWebOracleSelect we built in Chapter 8. You can find and download this project in the folder Class DB Projects\Chapter 8 in the Students folder at the CRC Press ftp site (refer to Figure 1.2 in Chapter 1).
6) Expand the package JavaWebOracleSelectPackage and copy all code inside the man-aged bean class FacultyQuery.java (exclude the imported packages at the top of this file).
7) In our opened managed bean FacultyMBean.java, paste all copied code inside this class.
Let’s first do some initial modifications to the FacultyMBean.java class file to make it our new Java Bean class (more modifications will be made later):
1) Change the class name from FacultyQuery to FacultyMBean. Change the construc-tor’s name from FacultyQuery() to FacultyMBean().
2) Remove the class MsgDialog and its object msgDlg code line, since we need to use theSystem.out.println() to replace it.
3) Replace all msgDlg.setMessage() and msgDlg.setVisible() with System. out.println() method.
4) Remove all original code inside the FacultyMBean class constructor.