Samrat Roy [http://community.jboss.org/people/whizkid.samrat] created the discussion
"Re: How to use task and state in jbpm 4.4" To view the discussion, visit: http://community.jboss.org/message/604404#604404 -------------------------------------------------------------- There are multiple ways of doing it .. the way i have tackled it is : Here is some sample code from my project.. I thought the best way was sharing related code. *// Controller code for .. notice approval or rejects comes from the same jsp in a parameter. : The task Id is the is id of the task created for the user .. {lookup taskservice.. } you will need this taskid to track actions performed on a task ..* protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException { String requestId = request.getParameter("requestId"); *String status = request.getParameter("status"); // approved OR rejected captured from JSP * * String taskId = request.getParameter("taskId");* String taskType=request.getParameter("taskType"); LoginUser loginUser =(LoginUser)request.getSession().getAttribute(MasterUtil.LOGGED_USER); *lmsService.approval(requestId,status,taskId,taskType,loginUser.getUsername()); // service method* Map retMap = new HashMap(); try { retMap.putAll(referenceData(request)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } //return new ModelAndView("redirect:/approveLeave.htm",retMap); return new ModelAndView(getFormView(),retMap); } // This is a method from lmsservice.. *lmsService.approval()* which takes care of the inputs from the controller. public void approval(String requestID, String status ,String taskId,String taskType,String userId) { if(status.equals("rejected")){ ApproveLeaveModel aml =leaveModuleDao.getLeaveRequestbyId(requestID); leaveModuleDao.manageLC(aml.getDays(),aml.getRequestorEmpCode(),aml.getDetails()); } //leaveModuleDao.changeLeaveStatus(requestID, status); Map<String,Object> variables = new HashMap<String,Object>(); *variables.put("decision", status); // this is where you setup a variable in the process .. let a decision state decide on the //basis of this variable and take the appropriate route .. attached my jpdl image* *taskService.setVariables(taskId, variables); // assign variable to the process instance.* if(taskType.equals("g")){ taskService.takeTask(taskId, userId); } * taskService.completeTask(taskId); // This completes a task marked by a specific task id* } -------------------------------------------------------------- Reply to this message by going to Community [http://community.jboss.org/message/604404#604404] Start a new discussion in jBPM at Community [http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
_______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
