📄 primarykeyaction.java
字号:
package com.y2.hr.config.primarykey.web.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.y2.hr.base.web.action.BaseAction;
import com.y2.hr.config.primarykey.bean.ConfigPrimaryKey;
import com.y2.hr.config.primarykey.web.form.PrimaryKeyForm;
public class PrimaryKeyAction extends BaseAction {
/**
* Method execute 关键字的添加
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
PrimaryKeyForm primaryKeyForm = (PrimaryKeyForm) form;
String msg = null;
if ("".equals(primaryKeyForm.getPrimaryKeyTable())
|| "".equals(primaryKeyForm.getPrimaryKey())
|| "".equals(primaryKeyForm.getKeyName())) {
msg = "请添关键字输入不允许为空!";
} else {
ConfigPrimaryKey primaryKey = new ConfigPrimaryKey();
try {
BeanUtils.copyProperties(primaryKey, primaryKeyForm);
} catch (Exception e) {
e.printStackTrace();
}
if (this.primaryKeyBiz.add(primaryKey)) {
return mapping.findForward("config_msg_ok");
} else {
msg = "新添关键字失败!";
}
}
request.setAttribute("msg", msg);
return mapping.findForward("config_msg_error");
}
/**
* Method execute 关键字页面中的跳转
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward toUrl(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String url = request.getParameter("url");
if ("success".equals(url)) {
this.showPage(request, 0, 0);
}
return mapping.findForward(url);
}
/**
* Method execute 页面中分页操作
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward doPage(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int count = Integer.parseInt(request.getParameter("count"));
int curPage = Integer.parseInt(request.getParameter("curPage"));
this.showPage(request, count, curPage);
return mapping.findForward("success");
}
/**
* 封装分页显示
*
* @param request
* @param count
* @param curPage
*/
private void showPage(HttpServletRequest request, int count, int curPage) {
if (0 == count && 0 == curPage) {
count = this.primaryKeyBiz.sum();
curPage = 1;
}
request.setAttribute("count", count);
request.setAttribute("curPage", curPage);
request.setAttribute("primarykeylist", this.primaryKeyBiz
.getPage(curPage));
}
/**
* Method execute 关键字删除操作
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String prkId = request.getParameter("prkId");
String msg = null;
ConfigPrimaryKey primaryKey = new ConfigPrimaryKey();
primaryKey.setPrkId((short) Integer.parseInt(prkId));
if (!this.primaryKeyBiz.del(primaryKey)) {
msg = "关键字删除失败!";
} else {
return mapping.findForward("config_msg_ok");
}
request.setAttribute("msg", msg);
return mapping.findForward("config_msg_error");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -