📄 contractmemoireaction.java
字号:
HttpServletResponse response) throws Exception {
//日志信息
if (log.isDebugEnabled()) {
log.debug("Entering 'initAddContractMemoireProcedure' method");
}
//得到动态Form
DynaActionForm dynaForm = (DynaActionForm) form;
Procedure procedure = (Procedure) dynaForm.get("searchBean");
//通过搜索Spring配置文件得到Provider业务类
//spring配置文件为:applicationContext-service-admin.xml
//对应的BeanID为:procedureService
ContractMemoireService service = (ContractMemoireService) getBean("contractMemoireService");
//定义pagination
Pagination pagination = new Pagination(request, "pagination");
List procedureNotIn = service.searchProcedureNotInContractMemoiresProcedure(contractID, procedure);
//调用service层的searchProcedure得到查询结果方法返回一个分页对象
pagination.setList(procedureNotIn);
//将得到的分页对象保存到request,给页面使用
request.setAttribute("pagination", pagination);
//重定向
return mapping.findForward("success");
}
public ActionForward initUpdateContractMemoireProcedure(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
//日志信息
if (log.isDebugEnabled()) {
log.debug("Entering 'initContractMemoire' method");
}
//通过搜索Spring配置文件得到ContractMemoire业务类
//spring配置文件为:applicationContext-service-admin.xml
//对应的BeanID为:contractMemoireService
ContractMemoireService service = (ContractMemoireService) getBean("contractMemoireService");
//得到动态Form
DynaActionForm dynaForm = (DynaActionForm) form;
String[] splitString = (String[]) dynaForm.get("idArr");
//通过动态Form的属性“searchBean” 得到ContractMemoire对象
ContractMemoireProcedure contractMemoireProcedure = (ContractMemoireProcedure) dynaForm.get("contractMemoireProcedureBean");
if(splitString!=null&&splitString.length!=0){
Long id = new Long(Long.parseLong(splitString[0]));
contractMemoireProcedure=service.getContractMemoireProcedure(id);
} else{
//通过页面上选择的将要编辑的记录的ID(对应于ContractMemoireProcedure对象的ID)得到ContractMemoire对象
contractMemoireProcedure = service.getContractMemoireProcedure(contractMemoireProcedure.getId());
}
//
if (contractMemoireProcedure == null) {
saveActionErrorMessage(request, TlmsServiceErrorCodes.SERVICE_ERROR_AD002);
//重定向:失败
return mapping.findForward("failure");
}
//1.ContractMemoire对象
request.setAttribute("contractMemoireProcedureBean", contractMemoireProcedure);
request.setAttribute("price", convertDoubleToString(contractMemoireProcedure.getPrice()));
//重定向:成功
return mapping.findForward("success");
}
public ActionForward addContractMemoireProcedure(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
DynaActionForm dynaForm = (DynaActionForm) form;
String[] splitString = (String[]) dynaForm.get("idArr");
if (splitString.length != 0 && splitString != null) {
//通过搜索Spring配置文件得到Provider业务类
//spring配置文件为:applicationContext-service-admin.xml
//对应的BeanID为:procedureService
ContractMemoireService service = (ContractMemoireService) getBean("contractMemoireService");
for (int i = 0; i < splitString.length; i++) {
ContractMemoireProcedure contractMemoireProcedure = new ContractMemoireProcedure();
contractMemoireProcedure.setContractMemoireID(contractID);
contractMemoireProcedure.setProcedureID(new Long(Long.parseLong(splitString[i])));
service.saveContractProcedure(contractMemoireProcedure);
}
}
//重定向:成功
return mapping.findForward("success");
}
public ActionForward updateContractMemoireProcedure(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
//日志信息
if (log.isDebugEnabled()) {
log.debug("Entering 'initAddContractMemoireProcedure' method");
}
//得到动态Form
DynaActionForm dynaForm = (DynaActionForm) form;
ContractMemoireProcedure contractMemoireProcedure = (ContractMemoireProcedure) dynaForm.get("contractMemoireProcedureBean");
String price = (String) dynaForm.get("price");
Double dprice = new Double(Double.parseDouble(price));
contractMemoireProcedure.setPrice(dprice);
//通过搜索Spring配置文件得到ContractMemoire业务类
//spring配置文件为:applicationContext-service-admin.xml
//对应的BeanID为:contractMemoireService
ContractMemoireService service = (ContractMemoireService) getBean("contractMemoireService");
//更新
service.saveContractProcedure(contractMemoireProcedure);
//重定向
return mapping.findForward("success");
}
public ActionForward removeContractMemoireProcedure(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
//日志信息
if (log.isDebugEnabled()) {
log.debug("Entering 'removeContractMemoire' method");
}
//得到动态Form
DynaActionForm dynaForm = (DynaActionForm) form;
//通过搜索Spring配置文件得到ContractMemoire业务类
//spring配置文件为:applicationContext-service-admin.xml
//对应的BeanID为:contractMemoireService
ContractMemoireService service = (ContractMemoireService) getBean("contractMemoireService");
//将要删除的ids
String[] splitString = (String[]) dynaForm.get("idArr");
//删除
service.removeContractMemoireProcedures(splitString);
//保存操作信息,对应的是ApplicationMessages资源文件中的“message.delete”
saveActionTripMessage(request, "message.delete");
//重定向
return mapping.findForward("success");
}
// ContractMemoireProcedure action end:
//SimpleListProcedure Actions Begin:
/**
* SimpleListProcedure search action
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward searchSimpleListProcedure(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
//日志信息
if (log.isDebugEnabled()) {
log.debug("Entering 'initSimpleListProcedure' method");
}
//得到动态Form
DynaActionForm dynaForm = (DynaActionForm) form;
//所选择的工序
String[] splitString = (String[]) dynaForm.get("idArr");
//测试
//for(int i = 0 ;i<splitString.length;i++){
// System.out.println("searchSimpleListProcedure "+splitString[i]);
//}
//通过搜索Spring配置文件得到Provider业务类
//spring配置文件为:applicationContext-service-admin.xml
//对应的BeanID为:procedureService
ProcedureService service = (ProcedureService) getBean("procedureService");
//Procedure对象
Procedure procedure = new Procedure();
//根据ID得到procedure对象
if (splitString != null) {
Long id = new Long(Long.parseLong(splitString[0]));
procedureID = id;
procedure = service.getProcedure(id);
}
//测试
//System.out.println("searchSimpleListProcedure "+procedure.getName());
procedureName = procedure.getName();
//重定向
return mapping.findForward("success");
}
/**
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward initSearchContractMemoire(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
//日志信息
if (log.isDebugEnabled()) {
log.debug("Entering 'initSearchContractMemoire' method");
}
//得到动态Form
DynaActionForm dynaForm = (DynaActionForm) form;
//通过动态Form的属性“searchBean” 得到ContractMemoire对象
ContractMemoire contractMemoire = (ContractMemoire) dynaForm.get("searchBean");
System.out.println("initSearchContractMemoire: " + contractMemoire.getOperatorID());
doSearchContractMemoire = contractMemoire;
//重定向
return mapping.findForward("success");
}
/**
* SimpleListProcedure action method
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward initSimpleListProcedure(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
//日志信息
if (log.isDebugEnabled()) {
log.debug("Entering 'initSimpleListProcedure' method");
}
//得到动态Form
DynaActionForm dynaForm = (DynaActionForm) form;
Procedure procedure = (Procedure) dynaForm.get("searchBean");
//通过搜索Spring配置文件得到Provider业务类
//spring配置文件为:applicationContext-service-admin.xml
//对应的BeanID为:procedureService
ProcedureService service = (ProcedureService) getBean("procedureService");
//定义pagination
Pagination pagination = new Pagination(request, "pagination");
//调用service层的searchProcedure得到查询结果方法返回一个分页对象
pagination = service.searchProcedure(pagination, procedure);
//将得到的分页对象保存到request,给页面使用
request.setAttribute("pagination", pagination);
//重定向
return mapping.findForward("success");
}
//SimpleListProcedure Actions end:
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -