How can I display the Form in Boriwser
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2010 07:51 AM
Hey all,
I try to start my Process programmatically, not in Activiti Explorer.
The process should start with a form: <startEvent id="theStart" activiti:formKey="resources/bookorder.form" />
What should I do, to see a form in browser.
I start and deploy a process in a servlet. This is a code:
Can I put the rendered HTML-String in the writer?
I tried to get the form with code: writer.println(formService.getRenderedStartForm("processDefId"));
Is it correct? How get I a processDefinitionId?
Best regards
Alexej
I try to start my Process programmatically, not in Activiti Explorer.
The process should start with a form: <startEvent id="theStart" activiti:formKey="resources/bookorder.form" />
What should I do, to see a form in browser.
I start and deploy a process in a servlet. This is a code:
public class ActivitiTestServlet extends HttpServlet { private static final long serialVersionUID = 1L; RepositoryService repositoryService; RuntimeService runtimeService; FormService formService; /** * @see HttpServlet#HttpServlet() */ public ActivitiTestServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try{ buildProcessEngine(); response.setStatus(200); PrintWriter writer = response.getWriter(); writer.println("<html>"); writer.println("<head><title>Hello World Servlet</title></head>"); writer.println("<body>"); writer.println(" <h1>Hello World from a Sevlet!</h1>"); writer.println("<body>"); writer.println("</html>"); writer.close(); } catch (Exception e){ System.out.println("Fehler: " + e); response.setStatus(404); } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } public void buildProcessEngine(){ ProcessEngine processEngine = new ProcessEngineBuilder() .configureFromResource("activiti.cfg.xml") .buildProcessEngine(); getServices(processEngine); deploy(); } public void deploy(){ String barFileName = "D:/workspace/ActivitiTestServlet/src/barFiles/bookorder.bar"; ZipInputStream inputStream = null; try { inputStream = new ZipInputStream(new FileInputStream( barFileName)); } catch (FileNotFoundException e) { System.out.println(e); e.printStackTrace(); } repositoryService.createDeployment().name(barFileName) .addZipInputStream(inputStream).deploy(); runtimeService.startProcessInstanceByKey("bookorder"); } public void getServices(ProcessEngine processEngine){ repositoryService = processEngine.getRepositoryService(); runtimeService = processEngine.getRuntimeService(); formService = processEngine.getFormService(); }}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Can I put the rendered HTML-String in the writer?
I tried to get the form with code: writer.println(formService.getRenderedStartForm("processDefId"));
Is it correct? How get I a processDefinitionId?
Best regards
Alexej
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2010 08:06 AM
Hi,
I don't think it's any problem to display the HTML by writing it to the response.
You can get hold of the process-definition using a process-definition-query
Or use the started processInstance's getProcessDefinitionId() method.
I don't think it's any problem to display the HTML by writing it to the response.
You can get hold of the process-definition using a process-definition-query
repositoryService.createProcessDefinitionQuery().processDefinitionKey("bookorder").singleResult();
Or use the started processInstance's getProcessDefinitionId() method.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2010 10:24 AM
thanks.
I think it should work, but i have another problem:
I have five deloyments of this process.
How can I delete them all, without to drop my DB?
For instance deleteDeploymentByKey or so…?
Alexej
I think it should work, but i have another problem:
I have five deloyments of this process.
How can I delete them all, without to drop my DB?
For instance deleteDeploymentByKey or so…?
Alexej
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2010 10:29 AM
You said it
First query for all deployments, for each of them call RepositoryService.deleteDeployment(xxx).
You should checkout the javadocs for the API, this contains a quick overview about what is possible with our API: http://activiti.org/javadocs/index.html
First query for all deployments, for each of them call RepositoryService.deleteDeployment(xxx).
You should checkout the javadocs for the API, this contains a quick overview about what is possible with our API: http://activiti.org/javadocs/index.html
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2010 11:33 AM
I read a javadoc, but it wasn't so clear for me.
The DeploymentQuery and ProcessDefinitionQuery have a same descripion….
Is it so correct:
I'v got it. The correct code:
The DeploymentQuery and ProcessDefinitionQuery have a same descripion….
Is it so correct:
List<Deployment> deployments = repositoryService.createDeploymentQuery().deploymentName("Book order").list();
for (int i = 0;i<deployments.size();++i){
Deployment deployment = deployments.get(i);
repositoryService.deleteDeployment(deployment.getId());
}
I'v got it. The correct code:
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_ID).list();
for (int i = 0;i<processDefinitions.size();i++){
repositoryService.deleteDeployment(processDefinitions.get(i).getDeploymentId());
}