8.5.3.4 Modify the FacultyProcess Page to Handle Faculty Data Deleting
Double-click on the FacultyProcess.jsp page in the Projects window to open this page, and perform the following modifications to this page to use the Java bean FacultyUpdateDeleteBean.java to perform the faculty record delete action:
1) Move the cursor to the else if (request.getParameter(“Delete”)!= null) block, just under that code line, then open the Palette window by going to Window > IDE Tools > Palette. In the opened Palette window, browse to the JSP tab, drag the Use Bean icon and place it inside the else if block.
2) In the opened Insert Use Bean dialog, enter DeleteFaculty in the ID field and
JavaWebOracleSelectPackage.FacultyUpdateDeleteBean in the Class field. Select session from the Scope combo box. Click on the OK button to close that dialog. A JSP directive that contains the bean id, bean scope and class is added to that block.
3) Add a JSP directive to the Java bean class FacultyUpdateDeleteBean.java as shown:
4) Add opening and ending JSP directives to enclose two JSP directives we added in steps 1 and 4 in Figure 8.95.
The code related to steps 1~4 is shown in the top on Figure 8.95. Add the code shown in steps A~D in Figure 8.95 into this block.
Let’s have a closer look at this code to see how it works.
A. A local integer variable, delete, is created and it is used to hold the run result of executing the DeleteFaculty() method in the Java bean class FacultyUpdateDeleteBean with the bean id of DeleteFaculty.
B. The getParameter() method is used to pick up the name of the faculty to be deleted from the Faculty Table. The retrieved faculty name is assigned to the local variable fname.
C. The DeleteFaculty() method in our Java bean is executed to delete a faculty record based on the selected faculty name from the Faculty Table. The run result of this method is returned and assigned to the local integer variable delete.
D. We need to re-display the Faculty.jsp page to enable users to perform the next action.