/** * Method execute * * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward updateCredencechar( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { try { IdAF idaf = (IdAF) form; String paraId = idaf.getId().toString(); ICredencecharBS credencecharBS = (ICredencecharBS) BSUtils.getBusinessService("credencecharBS", this, mapping.getModuleConfig()); // 根据ID判断记录是否存在 boolean temp_isCredencechar = credencecharBS.isCredencecharById(paraId); if (!temp_isCredencechar) { ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("该记录不存在,不能修改!", false)); saveErrors(request, messages); return mapping.findForward("credencecharShowAC"); } // 根据ID 查询出凭证字 和 凭证字名称 CredencecharDTO credencecharDTO = credencecharBS.queryCredencecharParamExplainInfo(paraId); String paramExplain = credencecharDTO.getParamExplain(); String paramExplainExplain = credencecharDTO.getParamExplainExplain(); request.setAttribute("paraId", paraId); request.setAttribute("paramExplain", paramExplain); request.setAttribute("paramExplainExplain", paramExplainExplain); request.setAttribute("updateInfo", "updateInfo"); } catch (Exception e) { e.printStackTrace(); } return mapping.findForward("credencecharShowAC"); }
private void validateFieldFormat( DynaActionForm form, ActionMessages errors, ResourceBundle bundle) { String[] buff = form.getStrings("scr23"); String[] stus = form.getStrings("studentNo"); scr23f = new double[buff.length]; for (int i = 0; i < buff.length; i++) { if (buff[i].equals("")) { errors.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.FieldCantEmpty", bundle.getString("Score"))); break; } else { try { scr23f[i] = (double) Math.round(Double.parseDouble(buff[i])); if (scr23f[i] > 100) { errors.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidScoreFormat", stus[i])); break; } } catch (Exception e) { e.printStackTrace(); errors.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.InvalidScoreFormat", stus[i])); } } } }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Recupera o Funcionário logado Long funcionarioId = (Long) request.getSession().getAttribute(Constants.PA_FUNCIONARIO); FuncionarioCtrl funcionarioCtrl = new FuncionarioCtrl(getDaoFactory()); Funcionario funcionario = (Funcionario) funcionarioCtrl.get(funcionarioId); ActionMessages msg = new ActionMessages(); String txtBusca = request.getParameter("txtBusca"); AjudaCtrl ajudaCtrl = new AjudaCtrl(getDaoFactory()); List lstAjuda = ajudaCtrl.consultaTextoAjuda(funcionario, txtBusca); // Se não encontrou resultado, coloca mensagem if (lstAjuda.isEmpty()) { msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.ajuda.consulta")); saveMessages(request, msg); } request.setAttribute("lstAjuda", lstAjuda); return mapping.findForward("success"); }
/** * Method execute * * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ActionMessages errors = new ActionMessages(); if (log.isInfoEnabled()) { log.info("FiltrarCliente1: Antes de entrar en la base de datos"); } HttpSession session = request.getSession(true); Consultar consultar = CreadorConsultar.CreaConsultar("cliente"); Vector listaClientes = consultar.filtrarClientes(form); if (listaClientes.size() == 0) { if (log.isInfoEnabled()) { log.info("FiltrarCliente 2: Ha habido un error en la búsqueda en la bbdd"); } errors.add("filtrarCliente", new ActionMessage("errors.listacliente.bbdd")); saveErrors(request, errors); return (mapping.findForward("error")); } else { if (log.isInfoEnabled()) { log.info("FiltrarCliente 3: Se ha realizado la busqueda con éxito"); } session.setAttribute("listaClientes", listaClientes); return mapping.findForward("exito"); } }
// 删除AA202表中记录,条件是:id=选择的id 除AA203表中记录,条件是:变更清册id=选择的id public ActionForward remove( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages messages = null; try { IdAF idaf = (IdAF) form; SecurityInfo securityInfo = (SecurityInfo) request.getSession().getAttribute("SecurityInfo"); String ip = securityInfo.getUserInfo().getUserIp(); String name = securityInfo.getUserInfo().getUsername(); String id = idaf.getId().toString(); IChgslarybaseBS chgslarybaseBS = (IChgslarybaseBS) BSUtils.getBusinessService("chgslarybaseBS", this, mapping.getModuleConfig()); chgslarybaseBS.deleteAllChgPaymentTailMaintain(new Integer(id), ip, name, securityInfo); messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("删除成功!", false)); saveErrors(request, messages); } catch (BusinessException e) { messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getMessage(), false)); saveErrors(request, messages); return mapping.findForward("chgslarybaseTbShowAC.do"); } return mapping.findForward("chgslarybaseTbShowAC.do"); }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages messages = null; try { String flowHeadId = request.getParameter("id"); if (flowHeadId != null && !flowHeadId.equals("null") && !flowHeadId.equals("")) { SecurityInfo securityInfo = (SecurityInfo) request.getSession().getAttribute("SecurityInfo"); IBizCheckBS bizCheckBS = (IBizCheckBS) BSUtils.getBusinessService("bizCheckBS", this, mapping.getModuleConfig()); AdjustAccountDTO adjustAccountDTO = bizCheckBS.queryAdjustAccountById(flowHeadId, securityInfo); adjustAccountDTO.setFlowHeadId(flowHeadId); request.getSession().setAttribute("adjustAccountDTO", adjustAccountDTO); } } catch (BusinessException bex) { messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(bex.getMessage(), false)); request.getSession().setAttribute("adjustAccountDTO", null); saveErrors(request, messages); } return mapping.findForward("to_adjustAccount_show"); }
/** * Validates that two fields match. * * @param bean * @param va * @param field * @param errors * @param request * @return boolean */ public static boolean validateTwoFields( Object bean, ValidatorAction va, Field field, ActionMessages errors, HttpServletRequest request) { String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); String sProperty2 = field.getVarValue("secondProperty"); String value2 = ValidatorUtils.getValueAsString(bean, sProperty2); if (!GenericValidator.isBlankOrNull(value)) { try { if (!value.equals(value2)) { errors.add(field.getKey(), Resources.getActionMessage(request, va, field)); return false; } } catch (Exception e) { errors.add(field.getKey(), Resources.getActionMessage(request, va, field)); return false; } } return true; }
// 撤消提交数据 public ActionForward pproval( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages messages = null; try { IdAF idaf = (IdAF) form; SecurityInfo securityInfo = (SecurityInfo) request.getSession().getAttribute("SecurityInfo"); String id = idaf.getId().toString(); IChgslarybaseBS chgslarybaseBS = (IChgslarybaseBS) BSUtils.getBusinessService("chgslarybaseBS", this, mapping.getModuleConfig()); String orgid = chgslarybaseBS.queryOrgidByChgPaymentHeadID(id); String flag = "2"; chgslarybaseBS.removePickInChgPaymentTailMaintain(id, orgid, securityInfo, flag); messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("撤消提交成功!", false)); saveErrors(request, messages); } catch (BusinessException e) { messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getMessage(), false)); saveErrors(request, messages); return mapping.findForward("chgslarybaseTbShowAC.do"); } return mapping.findForward("chgslarybaseTbShowAC.do"); }
public ActionForward update( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { IdAF idaf = (IdAF) form; String id = idaf.getId().toString(); Pagination pagination = new Pagination(); IChgslarybaseBS chgslarybaseBS = (IChgslarybaseBS) BSUtils.getBusinessService("chgslarybaseBS", this, mapping.getModuleConfig()); String orgid = chgslarybaseBS.findOrgidById(id); String type = "2"; pagination.getQueryCriterions().put("org.id", orgid); request.setAttribute("type", "0"); request.getSession().setAttribute(ChgslarybaseTaShowAC.PAGINATION_KEY, pagination); } catch (BusinessException e) { ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getMessage(), false)); saveErrors(request, messages); return mapping.findForward("chgslarybaseTbShowAC.do"); } return mapping.findForward("chgslarybaseTaShowAC.do"); }
/** * Process the specified HTTP request, and create the corresponding HTTP response (or forward to * another web component that will create it). Return an <code>ActionForward</code> instance * describing where and how control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param form * @param req * @param res * @param mapping The ActionMapping used to select this instance * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs * @return destination */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { ActionMessages errors = new ActionMessages(); ActionForward destination = null; if (!this.checkLogon(req)) { return mapping.findForward("logon"); } Integer action; try { action = Integer.parseInt(req.getParameter("action")); } catch (Exception e) { action = BlacklistAction.ACTION_LIST; } AgnUtils.logger().info("Action: " + action); try { destination = executeIntern(mapping, req, errors, destination, action); } catch (Exception e) { AgnUtils.logger().error("execute: " + e + "\n" + AgnUtils.getStackTrace(e)); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.exception")); } // Report any errors we have discovered back to the original form if (!errors.isEmpty()) { saveErrors(req, errors); } return destination; }
/** * 處理學生加選線上選課紀錄之方法 * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request javax.servlet.http.HttpServletRequest object * @param response javax.servlet.http.HttpServletResponse object * @return org.apache.struts.action.ActionForward object * @exception java.lang.Exception */ public ActionForward addCourse( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm aForm = (DynaActionForm) form; ActionMessages messages = validateInputForUpdate(aForm, Toolket.getBundle(request)); if (!messages.isEmpty()) { saveErrors(request, messages); return mapping.findForward(IConstants.ACTION_MAIN_NAME); } else { String stdNo = aForm.getString("stdNo"); ScoreManager sm = (ScoreManager) getBean(SCORE_MANAGER_BEAN_NAME); Student student = sm.findStudentByStudentNo(stdNo); if (student != null) { aForm.set("stdName", student.getStudentName()); aForm.set("stdClassName", Toolket.getClassFullName(student.getDepartClass())); aForm.set("sterm", "1"); aForm.set("classNo", ""); aForm.set("csCode", ""); } else { messages.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Course.errorN1", "查無此人個人資料")); saveErrors(request, messages); return mapping.findForward(IConstants.ACTION_MAIN_NAME); } } setContentPage(request.getSession(false), "course/OnlineAddCourse.jsp"); return mapping.findForward(IConstants.ACTION_MAIN_NAME); }
/** * Applies the selected errata * * @param mapping ActionMapping * @param formIn ActionForm * @param request ServletRequest * @param response ServletResponse * @return The ActionForward to go to next. */ public ActionForward applyErrata( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { Map<String, Object> params = new HashMap<String, Object>(); RequestContext requestContext = new RequestContext(request); StrutsDelegate strutsDelegate = getStrutsDelegate(); // if they chose errata, send them to the confirmation page Long sid = requestContext.getParamAsLong("sid"); User user = requestContext.getCurrentUser(); RhnSet set = getSetDecl(sid).get(user); // if they chose no errata, return to the same page with a message if (set.isEmpty()) { ActionMessages msg = new ActionMessages(); msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errata.applynone")); params = makeParamMap(formIn, request); strutsDelegate.saveMessages(request, msg); return strutsDelegate.forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD), params); } if (sid != null) { params.put("sid", sid); } return strutsDelegate.forwardParams(mapping.findForward(RhnHelper.CONFIRM_FORWARD), params); }
/** * 确定按钮 * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward edit( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages messages = null; // Object obj = new Object(); // String pl121Id = ""; // obj = (Object)request.getSession().getAttribute("pl121Id"); // if(obj!=null){ // pl121Id = obj.toString(); // } String pl121Id = (String) request.getSession().getAttribute("pl121Id"); EndorsecontractTbAF endorsecontractTbAF = (EndorsecontractTbAF) form; SecurityInfo securityInfo = (SecurityInfo) request.getSession().getAttribute("SecurityInfo"); IAssurepledgechgBS assurepledgechgBS = (IAssurepledgechgBS) BSUtils.getBusinessService("assurepledgechgBS", this, mapping.getModuleConfig()); try { assurepledgechgBS.addPledgeContract(pl121Id, securityInfo, endorsecontractTbAF, request); messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("操作成功!", false)); saveErrors(request, messages); } catch (BusinessException bex) { messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(bex.getMessage(), false)); saveErrors(request, messages); } return mapping.findForward("to_endorsecontractTbShowAC"); }
/* * (non-Javadoc) * * @see com.votingcentral.actions.DownloadAction#getStreamInfo(org.apache.struts.action.ActionMapping, * org.apache.struts.action.ActionForm, * javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ protected StreamInfo getStreamInfo( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); long millis = System.currentTimeMillis(); String fileName = ""; String contentType = ""; byte[] fileBytes = null; ShowPollResultsFormBean showResultsFormBean = (ShowPollResultsFormBean) form; String pollId = ""; pollId = VCRequestHelper.getValueFromRequestOrForm(request, RequestParameterObjects.POLL_ID, pollId); String questionId = showResultsFormBean.getQuestionId(); questionId = VCRequestHelper.getValueFromRequest( request, RequestParameterObjects.QUESTION_ID, questionId); showResultsFormBean.setPollId(pollId); showResultsFormBean.setQuestionId(questionId); PollTO pto = PollBO.getInstance().getPollByPollId(pollId); // if the user has not voted and the poll has not ended // redirect to show poll page. VCUserTO vto = UserBO.getInstance().getUserByUserName(VCRequestHelper.getUser(request)); Date now = PollTimeHelper.getInstance().getCurrentDate(); if (Votes.getInstance().canUserVote(vto.getUserId(), pollId) && pto.getEndTimestamp().after(now)) { log.debug("User has not voted, sending them to display poll."); errors.add( "pollId", new org.apache.struts.action.ActionMessage("show.poll.participation.reqd")); return null; } else { VCDownloadFileTypeEnum dfType = (showResultsFormBean.getDfType() == null ? VCDownloadFileTypeEnum.DEFAULT : VCDownloadFileTypeEnum.get(showResultsFormBean.getDfType())); if (dfType == VCDownloadFileTypeEnum.EXCEL) { fileName = "VC" + ".xls"; contentType = "application/vnd.ms-excel"; } else if (dfType == VCDownloadFileTypeEnum.TEXT) { fileName = "VC" + ".txt"; contentType = "text/plain"; fileBytes = getTextFormatBytes(pollId, questionId); } else if (dfType == VCDownloadFileTypeEnum.CSV) { fileName = "VC" + ".csv"; contentType = "application/vnd.ms-excel"; fileBytes = getTextFormatBytes(pollId, questionId); } } // set content type response.setHeader("Content-Type", "application/download"); // Set the content disposition response.setHeader("Content-disposition", "attachment; filename=" + fileName); response.setContentLength(fileBytes.length); response.setHeader("Pragma", "public"); response.setHeader("Cache-control", "must-revalidate"); return new ByteArrayStreamInfo(contentType, fileBytes); }
/** * 處理選擇修改學生選課內容之方法 * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request javax.servlet.http.HttpServletRequest object * @param response javax.servlet.http.HttpServletResponse object * @return org.apache.struts.action.ActionForward object * @exception java.lang.Exception */ public ActionForward modify( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm aForm = (DynaActionForm) form; ActionMessages messages = validateInputForUpdate(aForm, Toolket.getBundle(request)); if (!messages.isEmpty()) { saveErrors(request, messages); return mapping.findForward(IConstants.ACTION_MAIN_NAME); } else { String studentNo = aForm.getString("stdNo"); ScoreManager sm = (ScoreManager) getBean(SCORE_MANAGER_BEAN_NAME); Student student = sm.findStudentByStudentNo(studentNo); aForm.set("stdName", student.getStudentName()); aForm.set("stdClassName", Toolket.getClassFullName(student.getDepartClass())); SeldDataInfo sdi = getSeldDataInfoByIndex(request); if (sdi == null) { messages = new ActionMessages(); messages.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Course.onlineAddRemoveCourse.unselected")); saveErrors(request, messages); return mapping.findForward(IConstants.ACTION_MAIN_NAME); } request.setAttribute(SELD_DATA_INFO, sdi); } setContentPage(request.getSession(false), "course/ModifyCourse.jsp"); return mapping.findForward(IConstants.ACTION_MAIN_NAME); }
private AnalyzerTestMapping validateAnalyzerAndTestName( String analyzerId, String analyzerTestName, String testId, ActionMessages errors, boolean newMapping) { // This is not very efficient but this is a very low usage action if (GenericValidator.isBlankOrNull(analyzerId) || GenericValidator.isBlankOrNull(analyzerTestName) || GenericValidator.isBlankOrNull(testId)) { errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionError("error.all.required")); return null; } AnalyzerTestMapping existingMapping = null; AnalyzerTestMappingDAO mappingDAO = new AnalyzerTestMappingDAOImpl(); List<AnalyzerTestMapping> testMappingList = mappingDAO.getAllAnalyzerTestMappings(); for (AnalyzerTestMapping testMapping : testMappingList) { if (analyzerId.equals(testMapping.getAnalyzerId()) && analyzerTestName.equals(testMapping.getAnalyzerTestName())) { if (newMapping) { errors.add( ActionErrors.GLOBAL_MESSAGE, new ActionError("error.analyzer.test.name.duplicate")); return null; } else { existingMapping = testMapping; testMapping.setTestId(testId); break; } } } return existingMapping; }
@Override public ActionForward process( ActionMapping pActionMapping, ActionForm pActionForm, HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) { LoginForm lLoginForm = (LoginForm) pActionForm; String lSubmitAction = StringUtils.trimToNull(lLoginForm.getSubmitAction()); if (lSubmitAction != null) { if (SubmitActions.LOGIN.toString().equals(lSubmitAction)) { String lLoginName = lLoginForm.getLoginName(); String lPassword = lLoginForm.getPassword(); if (!mLoginService.doesUserExist(lLoginName)) { ActionMessages lActionMessages = new ActionMessages(); lActionMessages.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage(LOGIN_ERROR_KEY_PREFIX + ".loginname.notexists")); this.saveErrors(pHttpServletRequest, lActionMessages); lLoginForm.setNextPage(NavigateActions.DisplayLogin.toString()); return pActionMapping.findForward(NavigateActions.DisplayLogin.toString()); } boolean lAuthenticated = mLoginService.isUserAuthenticated(lLoginName, lPassword); if (lAuthenticated) { LOGGER.debug("Login Successful"); User lUser = mLoginService.loadUserByLoginName(lLoginName); pHttpServletRequest.getSession().setAttribute(LOGGED_IN_USER, lUser); lLoginForm.setNextPage("DisplayHomePage"); } lLoginForm.setNextPage(NavigateActions.DisplayHomePage.toString()); } } return pActionMapping.findForward(NavigateActions.DisplayLogin.toString()); }
protected ActionForward performAction( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String forward = FWD_SUCCESS; DynaActionForm dynaForm = (DynaActionForm) form; // get selected qaEvents String[] selectedIDs = (String[]) dynaForm.get("selectedIDs"); // get sysUserId from login module UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); String sysUserId = String.valueOf(usd.getSystemUserId()); List qaEvents = new ArrayList(); for (int i = 0; i < selectedIDs.length; i++) { QaEvent qaEvent = new QaEvent(); qaEvent.setId(selectedIDs[i]); qaEvent.setSysUserId(sysUserId); qaEvents.add(qaEvent); } ActionMessages errors = null; try { QaEventDAO qaEventDAO = new QaEventDAOImpl(); qaEventDAO.deleteData(qaEvents); // System.out.println("Just deleted QaEvent"); // initialize the form dynaForm.initialize(mapping); } catch (LIMSRuntimeException lre) { // bugzilla 2154 LogEvent.logError("QaEventDeleteAction", "performAction()", lre.toString()); request.setAttribute(IActionConstants.REQUEST_FAILED, true); errors = new ActionMessages(); ActionError error = null; if (lre.getException() instanceof org.hibernate.StaleObjectStateException) { error = new ActionError("errors.OptimisticLockException", null, null); } else { error = new ActionError("errors.DeleteException", null, null); } errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); forward = FWD_FAIL; } if (forward.equals(FWD_FAIL)) return mapping.findForward(forward); if ("true".equalsIgnoreCase(request.getParameter("close"))) { forward = FWD_CLOSE; } request.setAttribute("menuDefinition", "QaEventMenuDefinition"); return mapping.findForward(forward); }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages messages = new ActionMessages(); try { SecurityInfo securityInfo = (SecurityInfo) request.getSession().getAttribute("SecurityInfo"); ILoanerlogoutBS loanerlogoutBS = (ILoanerlogoutBS) BSUtils.getBusinessService("loanerlogoutBS", this, mapping.getModuleConfig()); String contractId = (String) request.getParameter("contractId"); if (contractId != null && !"".equals(contractId.trim())) { contractId = (String) request.getParameter("contractId"); } loanerlogoutBS.findLoanerlogouAvailable(contractId); loanerlogoutBS.saveLoanerlogouTa(contractId, securityInfo); request.setAttribute("save", "save"); } catch (BusinessException be) { messages.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage(be.getLocalizedMessage(), false)); saveErrors(request, messages); return mapping.findForward("loanerlogout_show"); } catch (Exception e) { e.printStackTrace(); } return mapping.findForward("loanerlogout_show"); }
/** * 设置权限 * * @param mapping * @param actionForm * @param request * @param response * @return * @throws Exception */ public ActionForward setPrivilege( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { long roleId = ParamUtil.getLongParameter(request, "roleId", 0); long[] appId = ParamUtil.getLongParameterValues(request, "appId"); for (int i = 0; i < appId.length; i++) { long id = ParamUtil.getLongParameter(request, "access" + appId[i], 0); if (id != 1) { appId[i] = 0; } } long[] funcId = ParamUtil.getLongParameterValues(request, "funcId"); boolean ret = sysDeptRoleService.saveRoleApplication(roleId, appId, funcId); ActionMessages messages = new ActionMessages(); if (ret) { // 保存成功 messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("role.app_success")); } else { // 保存失败 messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("role.app_failure")); } addMessages(request, messages); return mapping.findForward("show_msg"); }
/** * 處理確定更新學生選課內容之方法 * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request javax.servlet.http.HttpServletRequest object * @param response javax.servlet.http.HttpServletResponse object * @return org.apache.struts.action.ActionForward object * @exception java.lang.Exception */ public ActionForward update( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm aForm = (DynaActionForm) form; ActionMessages messages = validateInputForUpdate(aForm, Toolket.getBundle(request)); if (!messages.isEmpty()) { saveErrors(request, messages); return mapping.findForward(IConstants.ACTION_MAIN_NAME); } else { try { Short selectLimit = (Short) aForm.get("selectLimit"); CourseManager cm = (CourseManager) getBean(COURSE_MANAGER_BEAN_NAME); cm.txUpdateDtimeSelLimit(aForm.getString("dtimeOid"), selectLimit); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.ModifySuccessful")); saveMessages(request, messages); Toolket.resetCheckboxCookie(response, SELD_LIST_NAME); return mapping.findForward(IConstants.ACTION_SUCCESS_NAME); } catch (Exception e) { ActionMessages errors = new ActionMessages(); errors.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Exception.generic", e.getMessage())); saveErrors(request, errors); return mapping.findForward(IConstants.ACTION_MAIN_NAME); } } }
public ActionForward showTeacherCredits( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws NumberFormatException, FenixServiceException, ParseException { DynaActionForm teacherCreditsForm = (DynaActionForm) form; ExecutionSemester executionSemester = FenixFramework.getDomainObject((String) teacherCreditsForm.get("executionPeriodId")); Teacher requestedTeacher = FenixFramework.getDomainObject((String) teacherCreditsForm.get("teacherId")); User userView = Authenticate.getUser(); Teacher loggedTeacher = userView.getPerson().getTeacher(); if (requestedTeacher == null || loggedTeacher != requestedTeacher) { ActionMessages actionMessages = new ActionMessages(); actionMessages.add("", new ActionMessage("message.invalid.teacher")); saveMessages(request, actionMessages); return mapping.findForward("teacher-not-found"); } showLinks(request, executionSemester, RoleType.DEPARTMENT_MEMBER); getAllTeacherCredits(request, executionSemester, requestedTeacher); return mapping.findForward("show-teacher-credits"); }
/** * 修改 * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward ok( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm dForm = (DynaActionForm) form; ActionMessages error = new ActionMessages(); // 建立共用錯誤訊息 ActionMessages msg = new ActionMessages(); CourseManager manager = (CourseManager) getBean("courseManager"); String no[] = dForm.getStrings("no"); String sname[] = dForm.getStrings("sname"); String school_name[] = dForm.getStrings("school_name"); String fname[] = dForm.getStrings("fname"); String dname[] = dForm.getStrings("dname"); String engname[] = dForm.getStrings("engname"); String Oid[] = dForm.getStrings("Oid"); String editCheck[] = dForm.getStrings("editCheck"); Member me = getUserCredential(request.getSession(false)).getMember(); for (int i = 1; i < Oid.length; i++) { // System.out.println("editCheck["+i+"]="+editCheck[i]); if (!editCheck[i].equals("")) { if (!no[i].equals("")) { Dept dept = (Dept) manager.hqlGetBy("FROM Dept WHERE Oid='" + Oid[i] + "'").get(0); dept.setDname(dname[i]); dept.setEngname(engname[i]); dept.setFname(fname[i]); dept.setLastEditUser(me.getIdno()); dept.setNo(no[i]); dept.setSchoolName(school_name[i]); dept.setLastEditTime(new Date()); dept.setSname(sname[i]); try { manager.updateObject(dept); } catch (Exception e) { e.printStackTrace(); error.add( ActionErrors.GLOBAL_MESSAGE, new ActionError("Course.messageN1", dept.getFname() + "修改失敗")); } } } } if (!error.isEmpty()) { saveErrors(request, error); return unspecified(mapping, form, request, response); } else { // msg.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("Course.messageN1", "修改完成")); saveMessages(request, msg); } return unspecified(mapping, form, request, response); }
public ActionForward updatePaperFee( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (logger.isDebugEnabled()) { logger.debug( "updatePaperFee(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse) - start"); } ActionMessages _messages = new ActionMessages(); ActionForward _forward = mapping.findForward("success"); try { if (isCancelled(request)) { if (logger.isDebugEnabled()) { logger.debug("updatePaperFee() - Cancelled end."); } cancelledAction(mapping, request, response); return null; } saveBackButton(request, response); PaperFeeForm _form = (PaperFeeForm) form; TpaperRegistation _tpaperRegistation = _form.getPaperFee(); ManagerFeeService _service = ApplicationServiceLocator.getManagerFeeService(); _service.updatePaperRegistration(_tpaperRegistation); _messages.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("success.modify.paper.registration.message")); saveMessages(request, _messages); } catch (BusinessServiceException e) { logger.error( "updatePaperFee(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)", e); _messages.add("paperFeeError", new ActionMessage("errors.code." + e.getErrCode())); saveErrors(request, _messages); _forward = mapping.findForward("error"); } catch (CannotFoundRequestParameterException e) { logger.error( "updatePaperFee(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)", e); _messages.add("paperFeeError", new ActionMessage("errors.code.132")); saveErrors(request, _messages); _forward = mapping.findForward("error"); } catch (Exception e) { logger.error( "updatePaperFee(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)", e); _messages.add("paperFeeError", new ActionMessage("errors.code.97")); saveErrors(request, _messages); _forward = mapping.findForward("error"); } if (logger.isDebugEnabled()) { logger.debug( "updatePaperFee(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse) - end"); } return _forward; }
private void persisteError(HttpServletRequest request, ActionError error) { ActionMessages errors; errors = new ActionMessages(); errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); }
public void saveMessages(HttpServletRequest request, String messageKey, Object[] params) { ActionMessages messages = (ActionMessages) request.getAttribute(Globals.MESSAGE_KEY); if (messages == null) { messages = new ActionMessages(); } messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(messageKey, params)); saveMessages(request, messages); }
private void showRemoteCommandMsg(ActionMessages msgs, boolean before, String mode) { if (before) { msgs.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.remotecommandbefore." + mode)); } else { msgs.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.remotecommandafter." + mode)); } }
/** {@inheritDoc} */ public ActionForward execute( ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { RequestContext requestContext = new RequestContext(request); if (request.getParameter("dispatch") != null) { if (requestContext.wasDispatched("installconfirm.jsp.confirm")) { return executePackageAction(mapping, formIn, request, response); } } List<PackageListItem> items = getDataResult(request); Server server = requestContext.lookupAndBindServer(); /* * If we are removing a package that is not in a channel the server is * subscribed to, then the rollback will not work, lets give the user * a message telling them that. */ if (this instanceof RemoveConfirmSetupAction && server.hasEntitlement(EntitlementManager.PROVISIONING)) { for (PackageListItem item : items) { Map<String, Long> map = item.getKeyMap(); if (!SystemManager.hasPackageAvailable( server, map.get("name_id"), map.get("arch_id"), map.get("evr_id"))) { ActionMessages msgs = new ActionMessages(); msgs.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("package.remove.cant.rollback")); getStrutsDelegate().saveMessages(request, msgs); break; } } } DynaActionForm dynaForm = (DynaActionForm) formIn; DatePicker picker = getStrutsDelegate() .prepopulateDatePicker(request, dynaForm, "date", DatePicker.YEAR_RANGE_POSITIVE); request.setAttribute("date", picker); ActionChainHelper.prepopulateActionChains(request); request.setAttribute("system", server); requestContext.copyParamToAttributes(RequestContext.SID); request.setAttribute( ListTagHelper.PARENT_URL, request.getRequestURI() + "?sid=" + server.getId()); request.setAttribute(WIDGET_SUMMARY, getWidgetSummary()); request.setAttribute(HEADER_KEY, getHeaderKey()); request.setAttribute(DATA_SET, items); return getStrutsDelegate() .forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD), request.getParameterMap()); }
public ActionForward doAction( ActionMapping mapping, HttpServletRequest request, HttpServletResponse response) throws Exception { DataHandler handler = (DataHandler) request.getAttribute(BrowserFrameworkConstants.CLIENT_INFO); // get values for current location lat and lon, and also distUnit TxNode node = (TxNode) handler.getParameter("anchorLat"); long anchorLat = node != null ? node.valueAt(0) : -1; node = (TxNode) handler.getParameter("anchorLon"); long anchorLon = node != null ? node.valueAt(0) : -1; node = (TxNode) handler.getParameter("distUnit"); long distUnit = node != null ? node.valueAt(0) : 1; logger.debug("Lat:" + anchorLat + " Lon:" + anchorLon + "Dist Unit:" + distUnit); // convert distUnit to mi or km String scale = "mi"; if (distUnit != Constant.DUNIT_MILES) { scale = "km"; } // set attributes for anchor lat, lon, distUnit and scale request.setAttribute("anchorLat", anchorLat); request.setAttribute("anchorLon", anchorLon); request.setAttribute("distUnit", distUnit); request.setAttribute("scale", scale); try { logger.debug("ShareMovie... before"); ExecutorRequest[] executorRequests = requestParser.parse(request); ShareMovieResponse executorResponse = new ShareMovieResponse(); if (executorRequests != null && executorRequests.length > 0) { ExecutorDispatcher ac = ExecutorDispatcher.getInstance(); ac.execute(executorRequests[0], executorResponse, new ExecutorContext()); } if (executorResponse.getStatus() == ExecutorResponse.STATUS_FAIL) { request.setAttribute("errorCode", new Long(-1)); request.setAttribute("errorMsg", executorResponse.getErrorMessage()); return mapping.findForward("failure"); } responseFormatter.format(request, new ExecutorResponse[] {executorResponse}); logger.debug("ShareMovie... after"); return mapping.findForward("success"); } catch (Exception e) { ActionMessages msgs = new ActionMessages(); msgs.add("loginfailed", new ActionMessage("errors.movie.failed")); addErrors(request, msgs); return mapping.findForward("failure"); } }
/** * パラメータの入力チェックを行います. * * @return 表示するメッセージ */ public ActionMessages validate() { ActionMessages errors = new ActionMessages(); // 検索条件の有無チェック if (!StringUtil.hasLength(productCode)) { errors.add( ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.condition.insufficiency")); } return errors; }