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

📄 updatecustomeraction.java

📁 A J2EE & Jsp Example
💻 JAVA
字号:
/* * * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. *  * This software is the proprietary information of Sun Microsystems, Inc.   * Use is subject to license terms. * The code in this example is offered under the license at:  * http://wireless.java.sun.com/berkeley_license.html * */import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.*;import java.util.*;import javax.naming.*;import javax.ejb.*;import customerejb.*;import customerejb.CustomerTO;import customerejb.ICustomerTO;import org.apache.struts.action.Action;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.util.MessageResources;public class UpdateCustomerAction extends Action {        public static final String custTOAttribute = "customerForm";    public ActionForward perform(ActionMapping mapping,    ActionForm form,    HttpServletRequest request,    HttpServletResponse response)throws  java.io.IOException {                System.out.println("UpdateCustomerAction  ");        //turn our form instance into our custom form bean        CustomerForm customerForm = (CustomerForm) form;        String customerId =request.getUserPrincipal().getName();        System.out.println("UpdateCustomerAction customerId " + customerId);              CustomerTO customerTO = new CustomerTO(customerId ,        customerForm.getFirstName(),  customerForm.getLastName(),        customerForm.getStreet(),        customerForm.getCity(), customerForm.getState(),        customerForm.getZip(),        customerForm.getPhone(),        customerForm.getEmail());        CustomerDelegate bdelegate = null;        try {                        System.out.println("new CustomerDelegate ");            bdelegate = new CustomerDelegate();            bdelegate.updateCustomer(customerTO) ;            customerTO =(CustomerTO) bdelegate.getCustomer(customerId);                    } catch (Exception e) {            e.printStackTrace();            return mapping.findForward("failure");        }                customerForm.setCustomerId(customerId );        customerForm.setFirstName(customerTO.getFirstName());        customerForm.setLastName(customerTO.getLastName());        customerForm.setStreet(customerTO.getStreet());        customerForm.setCity(customerTO.getCity());        customerForm.setState(customerTO.getState());        customerForm.setZip(customerTO.getZip());        customerForm.setPhone(customerTO.getPhone());        customerForm.setEmail(customerTO.getEmail());                System.out.println("UpdateCustomerAction Storing the outForm in session object");        HttpSession session = request.getSession();        session.setAttribute(custTOAttribute, customerForm);                return mapping.findForward("success");                    }}

⌨️ 快捷键说明

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