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

📄 removeproductaction.java

📁 基于Struts的网络商店源码。使用Hibernate技术
💻 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.IProduct;
import com.sush.webstore.store.domain.IWebStoreFacade;
import com.sush.webstore.store.domain.facade.WebStorePOJO;

public class RemoveProductAction {

	private Long id;

	private IWebStoreFacade webStore = new WebStorePOJO();

	private ICart cart;

	public String execute() {

		if (!init())
			return "error";

		IProduct product = webStore.getProduct(id);

		if (product == null)
			return "error";

		return cart.removeProduct(product) ? "success" : "error";
	}

	/**
	 * @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;
	}

	/**
	 * @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;
	}
}

⌨️ 快捷键说明

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