⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customereditaction.java

📁 struts + hibernate + spring ssh 的源码练习
💻 JAVA
字号:
//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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -