📄 cancelorderaction.java
字号:
/*
* @author : Sujatha
* @Version : 1.0
*
* Development Environment : Oracle9i JDeveloper
* Name of the File : CancelOrderAction.java
* Creation/Modification History :
*
* Sujatha 14-Jan-2003 Created
*
*/
package oracle.otnsamples.vsm.actions.orders;
// IO and servlet API
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oracle.otnsamples.util.MessageCache;
import oracle.otnsamples.util.ServiceLocator;
import oracle.otnsamples.vsm.services.OrderException;
import oracle.otnsamples.vsm.services.OrderManagement;
import oracle.otnsamples.vsm.services.OrderManagementHome;
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;
/**
* This Action class cancels an order specified by the user.
*
* @author Sujatha
* @version 1.0
*/
public class CancelOrderAction extends Action {
/**
* This is the action called from the Struts framework to cancel an order
*
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
*/
public ActionForward execute(
ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
OrderManagementHome orderHome = null;
OrderManagement orderBean = null;
try {
orderHome =
(OrderManagementHome) ServiceLocator.getLocator().getService("OrderManagement");
orderBean = orderHome.create();
String orderID = (String) request.getParameter("orderID");
String itemID = (String) request.getParameter("itemID");
if(orderID != null && itemID != null) {
orderBean.cancelOrderItem(orderID, itemID);
request.setAttribute(
"message",
MessageCache.getMessage(
"message.cancelorder.success",
getLocale(request)));
}
} catch(OrderException ex) {
servlet.log("CancelOrderError", ex);
request.setAttribute(
"message",
MessageCache.getMessage(
ex.getMessageCode(),
getLocale(request)));
return mapping.findForward("display");
} catch(Exception ex) {
servlet.log("CancelOrderError", ex);
ActionErrors errors = new ActionErrors();
errors.add(
"OrderError", new ActionError("common.error", ex.getMessage()));
saveErrors(request, errors);
return mapping.findForward("error");
} finally {
try {
if(orderBean != null) {
orderBean.remove();
}
} catch(Exception ex) {
}
}
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -