customereditaction.java

来自「struts + hibernate + spring ssh 的源码练习」· Java 代码 · 共 94 行

JAVA
94
字号
//Created by MyEclipse Struts// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.2/xslt/JavaClass.xslpackage struts.action;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.actions.DispatchAction;import persistence.Customer;import persistence.bl.LibraryManager;import struts.form.CustomerEditForm;/**  * MyEclipse Struts * Creation date: 12-04-2004 *  */public class CustomerEditAction extends DispatchAction {  /**   * loads customer from the db and forwards to the edit form   * @param mapping   * @param form   * @param request   * @param response   * @return   */  public ActionForward prepareEdit(ActionMapping mapping, ActionForm form,      HttpServletRequest request, HttpServletResponse response) {    CustomerEditForm customerEditForm = (CustomerEditForm) form;        Long id = Long.valueOf(request.getParameter("id"));    LibraryManager libraryManager = new LibraryManager();        customerEditForm.setCustomer(libraryManager.getCustomerByPrimaryKey(id));        return mapping.findForward("editCustomer");  }    /**   * prepares the add form (actually only forwards to it)   * @param mapping   * @param form   * @param request   * @param response   * @return   */  public ActionForward prepareAdd(ActionMapping mapping, ActionForm form,      HttpServletRequest request, HttpServletResponse response) {    return mapping.findForward("addCustomer");  }    /**   * saves the customers and forwards to the list   * @param mapping   * @param form   * @param request   * @param response   * @return   */  public ActionForward saveCustomer(ActionMapping mapping, ActionForm form,      HttpServletRequest request, HttpServletResponse response) {    CustomerEditForm customerEditForm = (CustomerEditForm) form;    LibraryManager libraryManager = new LibraryManager();    libraryManager.saveCustomer(customerEditForm.getCustomer());        return mapping.findForward("customerList");  }  /**   * deletes the customers and forwards to the list   * @param mapping   * @param form   * @param request   * @param response   * @return   */  public ActionForward deleteCustomer(ActionMapping mapping, ActionForm form,      HttpServletRequest request, HttpServletResponse response) {    CustomerEditForm customerEditForm = (CustomerEditForm) form;    LibraryManager libraryManager = new LibraryManager();    libraryManager.removeCustomerByPrimaryKey(customerEditForm.getCustomer().getId());        return mapping.findForward("customerList");  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?