?? usermanageaction.java
字號:
package com.easyjweb.action;
import java.util.ArrayList;
import java.util.Collection;
import com.easyjf.util.CommUtil;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.CrudAction;
import com.easyjf.web.tools.DbPageList;
import com.easyjf.web.tools.IPageList;
import com.easyjweb.business.User;
/**
* 使用添刪改查action
* @author 大峽
*
*/
public class userManageAction extends CrudAction {
/**
* 查詢及分頁,通過實現AbstractCrudAction中的抽象方法實現
*/
public IPageList doQuery(WebForm form, int currentPage, int pageSize) {
String scope = "1=1";
Collection paras = new ArrayList();
String orderType = CommUtil.null2String(form.get("orderType"));
String orderField = CommUtil.null2String(form.get("orderField"));
String userName = CommUtil.null2String(form.get("queryUserName"));
String tel = CommUtil.null2String(form.get("queryTel"));
if (!userName.equals("")) {
scope += " and userName like ?";
paras.add("%" + userName + "%");
}
if (!tel.equals("")) {
scope += " and tel like ?";
paras.add("%" + tel + "%");
}
if (orderField.equals(""))// 默認按用戶名排序
{
orderField = "userName";
orderType = "desc";
}
if (!orderField.equals("")) {
scope += " order by " + orderField;
if (!orderType.equals(""))
scope += " " + orderType;
}
DbPageList pList = new DbPageList(User.class, scope, paras);
pList.doList(currentPage, pageSize);
return pList;
}
/**
* 這個方法負責根據Form中的數據轉換成java對象。
*
*/
public Object form2Obj(WebForm form) {
String cid = (String) form.get("cid");
User user = null;
if (cid != null && (!cid.equals("")))
user = User.read(cid);
if (user == null)
user = new User();
return form.toPo(user);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -