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

📄 productsaction.java

📁 hibernate annotation及acegi-security使用范例
💻 JAVA
字号:
package com.game.products.web.actions;

import java.util.Collection;

import org.acegisecurity.Authentication;
import org.acegisecurity.context.SecurityContextHolder;

import com.game.commons.AbstractAction;
import com.game.commons.Pager;
import com.game.commons.IPagerService;
import com.game.products.model.Products;
import com.game.products.services.iface.IProductsService;


public class ProductsAction extends AbstractAction {
	
	private IProductsService productsService;
	private IPagerService pagerService;
	
	private Products product;
	private Pager pager;
	
	protected Collection availableItems;
	protected String currentPage;
	protected String pagerMethod;
	protected String totalRows;
	protected String gameId;
	protected String queryName;
	protected String queryValue;
	protected String searchName;
	protected String searchValue;
	protected String queryMap;
	protected String startRow;
	
	public String list() throws Exception {
		
		this.setQueryName(this.getQueryName());
		this.setQueryValue(this.getQueryValue());
		this.setCurrentPage(this.getCurrentPage());
		this.setStartRow(this.getStartRow());
	
		
		int totalRow=productsService.getRows(this.getQueryName(),this.getQueryValue());
		pager=pagerService.getPager(this.getCurrentPage(), this.getPagerMethod(), totalRow);
		this.setCurrentPage(String.valueOf(pager.getCurrentPage()));
		this.setTotalRows(String.valueOf(totalRow));
		if(this.getStartRow()!=null)
			availableItems=productsService.getProducts(this.getQueryName(),this.getQueryValue(),pager.getPageSize(), Integer.parseInt(this.getStartRow()));
		else{
			availableItems=productsService.getProducts(this.getQueryName(),this.getQueryValue(),pager.getPageSize(), pager.getStartRow());
			this.setStartRow(String.valueOf(pager.getStartRow()));
		}
		
	
		this.setQueryName(this.getQueryName());
		this.setQueryValue(this.getQueryValue());
		
		this.setSearchName(this.getQueryName());
		this.setSearchValue(this.getQueryValue());
		
		//this.setCurrentPage(this.getCurrentPage());
		
		return SUCCESS;		 
	}
	
	public String load() throws Exception {
		if(gameId!=null)
			product = productsService.getProduct(gameId);
		else
			gameId=productsService.getMaxID();
		
		this.setCurrentPage(this.getCurrentPage());
		this.setStartRow(this.getStartRow());
		this.setQueryName(this.getQueryName());
		this.setQueryValue(this.getQueryValue());
	    return SUCCESS;
	}
	
	public String save() throws Exception {
		if(this.getProduct().getGamePrice().equals("")){
			this.getProduct().setGamePrice("0.0");
		}
		this.setCurrentPage(this.getCurrentPage());
		this.setStartRow(this.getStartRow());
		
		String id=this.getProduct().getGameId();
		Products pd=productsService.getProduct(id);
		
		
		
		if(pd == null)
			productsService.addProduct(this.getProduct());
		else
			productsService.updateProductd(this.getProduct());
		
		this.setQueryName(this.getQueryName());
		this.setQueryValue(this.getQueryValue());
			
	    return SUCCESS;
	}
	
	public String delete() throws Exception {
		this.setQueryName(this.getQueryName());
		this.setQueryValue(this.getQueryValue());
		this.setStartRow(this.getStartRow());
		this.setCurrentPage(this.getCurrentPage());
		
		productsService.deleteProduct(this.getGameId());
		
		return SUCCESS;
	}
	
	

	public Products getProduct() {
		return product;
	}

	public void setProduct(Products product) {
		this.product = product;
	}
	
	public Collection getAvailableItems() {
        return availableItems;
    }


	public String getCurrentPage() {
		return currentPage;
	}


	public void setCurrentPage(String currentPage) {
		this.currentPage = currentPage;
	}


	public String getPagerMethod() {
		return pagerMethod;
	}


	public void setPagerMethod(String pagerMethod) {
		this.pagerMethod = pagerMethod;
	}


	public Pager getPager() {
		return pager;
	}


	public void setPager(Pager pager) {
		this.pager = pager;
	}

	public String getTotalRows() {
		return totalRows;
	}


	public void setTotalRows(String totalRows) {
		this.totalRows = totalRows;
	}

	public String getGameId() {
		return gameId;
	}

	public void setGameId(String gameId) {
		this.gameId = gameId;
	}

	public String getQueryName() {
		return queryName;
	}

	public void setQueryName(String queryName) {
		this.queryName = queryName;
	}

	public String getQueryValue() {
		return queryValue;
	}

	public void setQueryValue(String queryValue) {
		this.queryValue = queryValue;
	}
	
	public String getSearchName() {
		return searchName;
	}

	public void setSearchName(String searchName) {
		this.searchName = searchName;
	}

	public String getSearchValue() {
		return searchValue;
	}

	public void setSearchValue(String searchValue) {
		this.searchValue = searchValue;
	}
	
	public String getQueryMap() {
		return queryMap;
	}

	public void setQueryMap(String queryMap) {
		this.queryMap = queryMap;
	}
	
	public String getStartRow() {
		return startRow;
	}

	public void setStartRow(String startRow) {
		this.startRow = startRow;
	}
	
	
	



	public IPagerService getPagerService() {
		return pagerService;
	}


	public void setPagerService(IPagerService pagerService) {
		this.pagerService = pagerService;
	}
	
	public IProductsService getProductsService() {
		return productsService;
	}

	public void setProductsService(IProductsService productsService) {
		this.productsService = productsService;
	}
	
}

⌨️ 快捷键说明

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