
FIGURE 9.45 The code for the Insert button event handler.
H. The add() method is used to pick up and add eight pieces of new faculty information into this new ArrayList instance, al. These eight pieces of new faculty information are entered by the user and stored in seven text fields and a File Chooser in the FacultyFrame window form. The toString() method is used to convert each piece of new faculty information obtained using the getText() method that returns an object data type to a String. The index is necessary since it is used to indicate the position of each parameter in this ArrayList. One point to be noted is the order of adding these text fields, which must be identical to the order of data columns in our Faculty Table.
I. A try-catch block is used to call our Web service operation, InsertFaculty(), to perform the faculty data insert 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.
J. The Web service operation InsertFaculty() is executed with the ArrayList instance al that has been filled with eight pieces of new faculty information as the argument of this method. The run result of that operation is returned and assigned to a Boolean variable, insert.
K. If the value of the variable insert is false, which means that no row has been inserted into our Faculty Table and this insertion has failed, the msgDlg instance is used to show this situation.
L. Otherwise, if the value of the insert variable is true, which means that this data inser-tion is successful, the new inserted faculty name will be added into the Faculty Name combo box ComboName using the addItem() method.
M. The catch block is used to track and display any possible exception during the Web ser-vice operation execution.
Now we are ready to build and run our client project to test its function.