📄 removeitemaction.java
字号:
package com.sush.webstore.store.web.struts;
import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.sush.webstore.store.domain.ICart;
import com.sush.webstore.store.domain.IItem;
import com.sush.webstore.store.domain.IWebStoreFacade;
import com.sush.webstore.store.domain.facade.WebStorePOJO;
public class RemoveItemAction {
private Long id;
private IWebStoreFacade webStore = new WebStorePOJO();
private ICart cart;
public String execute() {
if (!init())
return "error";
IItem item = webStore.getItem(id);
if (item == null)
return "error";
return cart.removeItem(item) ? "success" : "error";
}
/**
* @return the cart
*/
public ICart getCart() {
return cart;
}
/**
* @param cart
* the cart to set
*/
public void setCart(ICart cart) {
this.cart = cart;
}
/**
* @return the id
*/
public Long getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(Long id) {
this.id = id;
}
/**
* @return the webStore
*/
public IWebStoreFacade getWebStore() {
return webStore;
}
/**
* @param webStore
* the webStore to set
*/
public void setWebStore(IWebStoreFacade webStore) {
this.webStore = webStore;
}
/**
* @return the cart
*/
public boolean init() {
Map session = (Map) ActionContext.getContext().get("session");
if (session == null) {
return false;
}
cart = (ICart) session.get("cart");
return (cart == null) ? false : true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -