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

📄 userprofilesearchaction.java

📁 j2ee源码
💻 JAVA
字号:
package com.leeman.wkexs.master.userprofile.web;

import java.util.ArrayList;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.leeman.common.util.Formatter;
import com.leeman.common.web.ui.CachedPager;
import com.leeman.wkexs.master.users.entity.UsersSO;
import com.leeman.wkexs.master.users.entity.UsersVO;
import com.leeman.wkexs.master.users.handler.UsersHandler;
import com.leeman.wkexs.master.users.handler.UsersHandlerHelper;
import com.leeman.wkexs.web.base.BaseConstants;
import com.leeman.wkexs.web.base.BaseSearchAction;

public final class UserProfileSearchAction extends BaseSearchAction
{	
  	public void doInit(ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception
  	{
		UserProfileCollectionCache cache = new UserProfileCollectionCache();		
		this.setCollectionCache(request, cache);
  	}
  	  	
  	public void initSearchForm(ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) throws Exception
  	{
		SearchForm searchForm = (SearchForm) form;
		
		ArrayList deptIdList = this.getSysXlatItemListByFieldWithBlank(BaseConstants.XLAT_DEPT, getLangId(request));
		searchForm.setDeptIdList(deptIdList);
		
		ArrayList activeList = this.getSysXlatItemListByFieldWithBlank(BaseConstants.XLAT_ACTIVE_TYPE, getLangId(request));
		searchForm.setActiveList(activeList);
  	}
  	
  	public void doSearch(ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception
  	{		
		SearchForm searchForm = (SearchForm)form;
		
		//Do the Searching
		UserProfileCollectionCache collectionCache = (UserProfileCollectionCache)getCollectionCache(request);
		UsersSO searchKey = (UsersSO)collectionCache.getSearchKey();
		CachedPager pager = collectionCache.getSearchPager();
				
		UsersHandler handler = UsersHandlerHelper.getUsersHandler();
		ArrayList result = handler.getList(searchKey, pager.calcCacheRecordStart(), pager.getCacheRecordSize());
		handler.remove();
		
		/*Map map = this.getSysXlatItemShotDesc(BaseConstants.XLAT_DEPT,getLangId(request));
		Map map1 = this.getSysXlatItemShotDesc(BaseConstants.XLAT_ACTIVE_TYPE,getLangId(request));
		for(int i=0; i<result.size(); i++)
		{
			UsersVO tempVO = (UsersVO)result.get(i);
			//if (String.valueOf(tempVO.getSalesman_id()).equals("0"))
			//	tempVO.setSalesman_id(null);
			tempVO.setDept_id_desc((String)map.get(tempVO.getDept_id()));
			tempVO.setActivate_desc((String)map1.get(tempVO.getActive()));
			result.set(i,tempVO);
		}*/
				
		pager.setCachedRange(pager.calcCacheRecordStart(), result.size());		
		collectionCache.setSearchResults(result);
  	}
  	
  	protected void updateCollectionCache(HttpServletRequest request, ActionForm form) throws Exception
  	{
  		UserProfileCollectionCache collectionCache = (UserProfileCollectionCache)getCollectionCache(request);
		SearchForm searchForm = (SearchForm)form;
		UsersSO so = new UsersSO();
		so.setCompany_id(getCompanyId(request));
		so.setUser_id(searchForm.getUser_id().trim());
		so.setName(searchForm.getName().trim());
		so.setRole_id(searchForm.getRole_id().trim());
		so.setDept_id(searchForm.getDept_id().trim());
		so.setActive(searchForm.getActive());
		so.setPosition(searchForm.getPosition().trim());
	
		collectionCache.setSearchKey(so);	
  	}
  	
	/**
	 * Overrides
	 */
	public void loadFormFromCache(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {
		UserProfileCollectionCache collectionCache = (UserProfileCollectionCache)getCollectionCache(request);
		UsersSO so = (UsersSO)collectionCache.getSearchKey();
		SearchForm searchForm = (SearchForm)form;
		
		searchForm.setUser_id(so.getUser_id().trim());
		searchForm.setName(so.getName().trim());
		searchForm.setRole_id(so.getRole_id().trim());
		searchForm.setDept_id(so.getDept_id().trim());
		searchForm.setActive(so.getActive().trim());
		searchForm.setPosition(so.getPosition().trim());
	}
	
	/**
	 * Overrides
	 */
	public void doNewSearch(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {
		super.doNewSearch(mapping, form, request, response);
		this.setInitFocus(request, "document.forms[0].user_id");
	}
}

⌨️ 快捷键说明

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