?? priceaction.java
字號:
package controller;import javax.servlet.http.*;import org.apache.struts.action.*;import model.*;import java.util.*;import java.util.ArrayList;public class PriceAction extends Action { private final static String SUCCESS = "success"; private static Order order; private static Order order1; private static List<OrderItem> what_ordered = new ArrayList<OrderItem>(); public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // if (form instanceof ProductHandler) { ProductHandler f = (ProductHandler) form; // CheckHandler f1 = (CheckHandler) form; if (f.getButton3() != null) { ActionMessages errors = new ActionErrors(); if (f.getTf().startsWith("-")) { errors.add("Quantity", new ActionMessage("errors.negative", "Quantity")); this.saveErrors(request, errors); return mapping.findForward("reentrant"); } else { int id = Integer.parseInt(f.getRbg()); int qt = Integer.parseInt(f.getTf()); what_ordered.add(new OrderItem(id, qt, ProductsBean.findPrice(id))); order1 = new Order(null, what_ordered); f.setOrder1(order1); f.setTf(null); f.setRbg(null); f.setButton3(null); this.saveErrors(request, errors); return mapping.findForward("reentrant"); } } else if (f.getButton1() != null) { ActionMessages errors = new ActionErrors(); String user = f.getTf1(); if (!user.equals("")) { order = new Order(user.toUpperCase(), what_ordered); OrdersBean.create(order); f.setOrder(order); what_ordered = new ArrayList<OrderItem>(); f.setOrder1(null); f.setTf1(""); f.setButton1(null); return mapping.findForward("external"); } errors.add("username", new ActionMessage("errors.required", "username")); this.saveErrors(request, errors); return mapping.findForward("reentrant"); } return mapping.findForward(SUCCESS); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -