The practice of small semesters is coming to an end unconsciously.
The project is almost complete, this time I'll talk about how to delete the customer information to do, in fact, his operation and save the new customer information is similar.
First, in the front-end custinfo.jsp, there is a delete button.
<s:a href= "delectcust.action?cust.id=%{#cust. ID}" onclick= "return Fundelete ();" > Delete </s:a>
It does the request transformation through the Strust.xml file as an intermediate file:
1 <!-- delete --> 2 < Action name = "Delectcust" class = "Removecustaction" > 3 < Result > /jsp/custinfo.jsp</ result > 4 </ Action >
This class of removecustaction in this file corresponds to the corresponding name in the Applicationcontext.xml file:
1 <!--configuration-delete deleteaction -2 <BeanID= "Removecustaction"class= "Com.crm.action.RemoveCustAction">3 < Propertyname= "Custservice"ref= "Custservice"></ Property>4 </Bean>
This configuration also corresponds to the Removecustaction class, which is the implementation of deleting this action
1 Packagecom.crm.action;2 3 ImportCom.crm.bean.Cust;4 ImportCom.crm.service.CustService;5 ImportCom.opensymphony.xwork2.ActionSupport;6 7@SuppressWarnings ("Serial")8 Public classRemovecustactionextendsactionsupport{9 Ten PrivateCust Cust; One PrivateCustservice Custservice; A - PublicCustservice Getcustservice () { - returnCustservice; the } - - Public voidSetcustservice (Custservice custservice) { - This. Custservice =Custservice; + } - +@SuppressWarnings ("Unchecked") A @Override at PublicString Execute ()throwsException { - This. Custservice.removecustomer (Cust); - returnSUCCESS; - } - - PublicCust Getcust () { in returnCust; - } to + Public voidsetcust (Cust Cust) { - This. Cust =Cust; the } * $}
Add a statement to the two classes in Custdao and Custservice
Public void removecustomer (Cust Cust);
And in the two corresponding implementation files (IMPL), add the following statements, respectively
1 Public void Removecustomer (Cust Cust) {2 // TODO auto-generated Method Stub 3 This . Gethibernatetemplate (). Delete (Cust); 4 }
1 Public void Removecustomer (Cust Cust) {2 // TODO auto-generated Method Stub 3 This . Custdao.removecustomer (Cust); 4 }
MyEclipse (iii)