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

📄 netstorelookupdispatchaction.java

📁 网上商店 新增功能: 1
💻 JAVA
字号:
package netstore.framework;import javax.servlet.http.*;import netstore.framework.util.IConstants;import netstore.service.*;import org.apache.struts.actions.LookupDispatchAction;/** * 一个表单中多个按钮 button.checkout = Check Out button.saveorder = Save Order *  * 在Action中 getKeyMethodMap(){ Map map = new HashMap(); * map.put("button.checkout","checkout"); ......... } *  * @author huangyongfeng *  */abstract public class NetstoreLookupDispatchAction extends LookupDispatchAction {	protected INetstoreService getNetstoreService() {		INetstoreServiceFactory factory = (INetstoreServiceFactory) getApplicationObject(IConstants.SERVICE_FACTORY_KEY);		INetstoreService service = null;		try {			service = factory.createService();		} catch (Exception ex) {			log.error("Problem creating the Netstore Service", ex);		}		return service;	}	protected CustServiceImpl getCustService() {		INetstoreServiceFactory factory = (INetstoreServiceFactory) getApplicationObject(IConstants.SERVICE_FACTORY_KEY);		CustServiceImpl service = null;		try {			service = factory.createCustService();		} catch (Exception ex) {			log.error("Problem creating the Netstore Service", ex);		}		return service;	}	protected ProdServiceImpl getProdService() {		INetstoreServiceFactory factory = (INetstoreServiceFactory) getApplicationObject(IConstants.SERVICE_FACTORY_KEY);		ProdServiceImpl service = null;		try {			service = factory.createProdService();		} catch (Exception ex) {			log.error("Problem creating the Netstore Service", ex);		}		return service;	}	protected OrderServiceImpl getOrderService() {		INetstoreServiceFactory factory = (INetstoreServiceFactory) getApplicationObject(IConstants.SERVICE_FACTORY_KEY);		OrderServiceImpl service = null;		try {			service = factory.createOrderService();		} catch (Exception ex) {			log.error("Problem creating the Netstore Service", ex);		}		return service;	}	/**	 * Retrieve an object from the application scope by its name. This is a	 * convience method.	 */	protected Object getApplicationObject(String attrName) {		return servlet.getServletContext().getAttribute(attrName);	}	/**	 * Retrieve the SessionContainer for the user tier to the request.	 */	protected SessionContainer getSessionContainer(HttpServletRequest request) {		SessionContainer sessionContainer = (SessionContainer) getSessionObject(				request, IConstants.SESSION_CONTAINER_KEY);		System.out.println(sessionContainer);		// Create a SessionContainer for the user if it doesn't exist already		if (sessionContainer == null) {			sessionContainer = new SessionContainer();			sessionContainer.setLocale(request.getLocale());			HttpSession session = request.getSession();			session.setAttribute(IConstants.SESSION_CONTAINER_KEY,					sessionContainer);		}		return sessionContainer;	}	/**	 * Retrieve a session object based on the request and the attribute name.	 */	protected Object getSessionObject(HttpServletRequest req, String attrName) {		Object sessionObj = null;		HttpSession session = req.getSession(false);		System.out.println("Session was " + session);		if (session != null) {			sessionObj = session.getAttribute(attrName);		}		return sessionObj;	}}

⌨️ 快捷键说明

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