📄 empinfoaction.java
字号:
package com.szmx.tlms.study.web;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import com.szmx.framework.base.model.Pagination;
import com.szmx.framework.base.web.BaseAction;
import com.szmx.tlms.study.model.DemoEmpInfo;
import com.szmx.tlms.study.service.DeptInfoService;
import com.szmx.tlms.study.service.EmpInfoService;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class EmpInfoAction extends BaseAction {
public ActionForward listEmpInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'listEmpInfo' method");
}
DynaActionForm dynaForm = (DynaActionForm) form;
DemoEmpInfo empInfo = (DemoEmpInfo) dynaForm.get("searchBean");
Pagination pagination = new Pagination(request, "pagination");
EmpInfoService mgr = (EmpInfoService) getBean("empInfoService");
pagination = mgr.listEmpInfo(pagination, empInfo);
request.setAttribute("pagination", pagination);
return mapping.findForward("success");
}
public ActionForward initAddEmpInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'listEmpInfo' method");
}
DeptInfoService mgr = (DeptInfoService) getBean("deptInfoService");
List list = mgr.getAllDeptInfo();
request.setAttribute("deptlist", list);
return mapping.findForward("success");
}
public ActionForward saveEmpInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'listEmpInfo' method");
}
//get data from request
DynaActionForm dynaForm = (DynaActionForm) form;
DemoEmpInfo empInfo = (DemoEmpInfo) dynaForm.get("empInfoBean");
String wsdlUrl = "http://localhost:8018/tlms/services/myWebService?wsdl";
String nameSpaceUri = "http://localhost:8018/tlms/services/myWebService";
// 创建调用对象
Service service = new Service();
Call call = null;
call = (Call) service.createCall();
// 调用 getMessage
System.out.println(">>>getMessage");
call.setOperationName(new QName(nameSpaceUri, "checkLoginName"));
call.setTargetEndpointAddress(new java.net.URL(wsdlUrl));
String ret = (String) call.invoke(new Object[] { empInfo.getLoginName() });
if (ret.equals("true")){
return mapping.findForward("failure");
}
System.out.println("return value is " + ret);
//save data
EmpInfoService mgr = (EmpInfoService) getBean("empInfoService");
mgr.save(empInfo);
return mapping.findForward("success");
}
public ActionForward initUpdateEmpInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("Entering 'listEmpInfo' method");
}
DeptInfoService mgr = (DeptInfoService) getBean("deptInfoService");
List list = mgr.getAllDeptInfo();
request.setAttribute("deptlist", list);
EmpInfoService mgrEmpInfo = (EmpInfoService) getBean("empInfoService");
DynaActionForm dynaForm = (DynaActionForm) form;
DemoEmpInfo empInfo = (DemoEmpInfo) dynaForm.get("empInfoBean");
DemoEmpInfo demoEmpInfo = mgrEmpInfo.getEmpInfo(empInfo.getId());
request.setAttribute("empInfoBean", demoEmpInfo);
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -