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

📄 shophandler.java

📁 电子商务网站前台代码。基于开源软件编写
💻 JAVA
字号:
package handler;
import javax.ejb.CreateException;
import javax.faces.context.FacesContext;
import javax.naming.NamingException;

import session.interfaces.UserLocal;
import session.interfaces.UserLocalHome;
import session.interfaces.UserUtil;
import dao.ShopUserTO;
import bean.ShopUserBean;

/**
 * 
 */

/**
 * @author Administrator
 *
 */
public final class ShopHandler extends Object {

	/**
	 * 
	 */
	private ShopUserBean shop = (ShopUserBean)(FacesContext.getCurrentInstance().getApplication().createValueBinding("#{shop}").getValue(FacesContext.getCurrentInstance()));
	
	private String loginName;	
	
	public ShopHandler() {
		super();		
		System.out.println("init shopHandler");				
		// TODO Auto-generated constructor stub
	}	

	public String getLoginName(){
		loginName = FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();				
		this.shop = this.getCurrentShop(loginName,this.shop);	
		
		return loginName;
	}
	
	public void setLoginName(String loginname){
		this.loginName = loginname;
	}
	
	public ShopUserBean getCurrentShop(String login,ShopUserBean tempshop){
		UserLocalHome localhome = null;			
		try {
			localhome = UserUtil.getLocalHome();			
			UserLocal userlocal = localhome.create();
			ShopUserTO userTo = userlocal.selectShopUser(login);	
			
			
			tempshop.setUserName(userTo.getUserName());
			tempshop.setShopName(userTo.getShopName());
			tempshop.setShopId(userTo.getShopId());	
			
			
		} catch (NamingException e1) {
		// TODO Auto-generated catch block			
			e1.printStackTrace();			
		} catch (CreateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();			
		}				
		return tempshop;
	}

	/**
	 * @return Returns the shop.
	 */
	public ShopUserBean getShop() {
		return shop;
	}

	/**
	 * @param shop The shop to set.
	 */
	public void setShop(ShopUserBean shop) {
		
		this.shop = shop;
	}

	
	public String checkName(){
		UserLocalHome localhome = null;
		boolean outcome = false;
		try {
			localhome = UserUtil.getLocalHome();			
			UserLocal userlocal = localhome.create();
			ShopUserTO userTo = userlocal.selectShopUser(shop.getUserName());	
			if(userTo==null)outcome=true;		
		} catch (NamingException e1) {
		// TODO Auto-generated catch block			
			e1.printStackTrace();
			outcome=false;
			
		} catch (CreateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			outcome=false;
		}	
		
		if(outcome)shop.setMessage("right");
		else shop.setMessage("wrong");		
		return "success";
	}
	
	public String registerShop(){		
		UserLocalHome localhome = null;
		try {  
			localhome = UserUtil.getLocalHome();	
			ShopUserTO userTo = new  ShopUserTO(
												 shop.getProvince()+shop.getCity()+shop.getZone()+shop.getBtrade()+shop.getStrade(),
												 shop.getUserName(),
												 shop.getPassword(),
												 shop.getRole(),
												 shop.getShopName(), 												 
												 shop.getAddress(), 
												 shop.getRealName(),
												 shop.getPosition(),
												 shop.getSex(),
												 shop.getEmail(),	
												 shop.getPhone(),
												 shop.getDescribe(),
												 shop.getFax()); 		
			UserLocal shoplocal = localhome.create();
			shoplocal.insertShopUser(userTo);				
			return "success";
		
		} catch (NamingException e1) {
		// TODO Auto-generated catch block		
			e1.printStackTrace();
			return "failure";
			
		} catch (CreateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "failure";
		}			
		//return "failure";
	}
}

⌨️ 快捷键说明

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