9.13.2 Develop the Code to Call Our Web Service Operation UpdateFaculty()
The main coding process includes two parts: generate code in the Java managed bean class FacultyMBean.java and add code into the Control class FacultyProcess.jsp page.
A binding relationship between the action attribute of the Update command Button in our JSP page Faculty.jsp and the Update _ Faculty() method that will be built in our Java man-aged bean FacultyMBean.java has been established. Therefore we can concentrate on the code developments for the Update _ Faculty() method in our Java managed bean class.
Open our Web-based client project, WebClientFaculty _ UpdtDelt, and double-click on the FacultyMBean.java in the Projects window to open this managed bean class file. Add the code shown in Figure 9.65 as a new method, Update _ Faculty(), into this class file; locate it just under the InsertFaculty() method.

FIGURE 9.65 The new generated code for the Update_Faculty() method.
Let’s have a closer look at this piece of new added code to see how it works.
A. The Update _ Faculty() method is declared with a string array, upFaculty, as the argument, with all eight pieces of updated faculty information. The name of this method, Update _ Faculty(), is used to distinguish it from our Web service opera-tion UpdateFaculty().
B. First some local variables are declared, including an integer variable, numUpdated, that will hold the data update result later, and a new ArrayList instance, al, that is used to pick up and reserve the input updated faculty data array.
C. The clear() method is executed to make sure that the ArrayList instance is clean before an updated faculty record can be collected.
D. A sequence of add() methods are used to pick up and add all pieces of updated faculty information into the new ArrayList instance, al. Seven pieces of updated faculty informa-tion are entered by the user in the JSP page Faculty.jsp and stored in seven properties defined in this managed bean. The last parameter, the eighth one, is the original faculty ID.
E. A try-catch block is used to perform the calling of our Web service operation UpdateFaculty() to perform this faculty data update action. First a new Web service instance, service, is created based on our Web service class, WebServiceFaculty _ Service. Then the getWebServiceFacultyPort() method is executed to get the current port used by our Web service. This port is returned and assigned to a new port instance, port.
F. The UpdateFaculty() operation in our Web service is called with the ArrayList instance that contains all pieces of updated faculty information as the argument. The exe-cution result of this faculty data update is returned and assigned to the local Boolean vari-able, update.
G. If the returned Boolean variable update is false, which means that the data update fails, the system method System.out.println() is used to indicate this situation, and a zero is returned to the client project.
H. The catch block is used to catch any possible exception during the data update process.
A zero is returned to the client project if any exception really occurs.
I. Finally, the local variable numUpdated is returned to indicate that the data update action is successful.
Prior to running our client project to test the data update action, let’s first finish the code develop-ment for the Delete _ Faculty() method in our managed bean, FacultyMBean.java, that is used to call our Web service operation DeleteFaculty() to perform the faculty data delete action.