<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to dynamically start a task from a process that was started from an HTML Dialog</title><link>https://answers.axonivy.com/questions/1383/how-to-dynamically-start-a-task-from-a-process-that-was-started-from-an-html-dialog</link><description>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;In a JSF Dialog we can start a task dynamically with: &lt;/p&gt;&lt;pre&gt;&lt;code&gt;FacesContext.getCurrentInstance().getExternalContext().redirect(ivy.html.taskstartref(ivy.wf.findTask(95)));&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We can also start an IProcess dynamically with something like that:
&lt;/p&gt;&lt;pre&gt;&lt;code&gt;IRequest request = requestFactory.createRequest(processStart, thisMapOrEmptyMapIfNull(params)); 
IResponse response = responseFactory.createResponse(); 
IRequestHandler requestHandler = (IRequestHandler)processStart.getProcessModelVersion().getAdapter(IProcessEngine.class); 
requestHandler.handleRequest(request, response);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now we would like to combine both to start a process dynamically that should in turn start a task.
The process can be started from within the JSF Dialog.&lt;br&gt;
In the started process, as we are not in the JSF context, the following does not work (fails silently):&lt;/p&gt;&lt;pre&gt;&lt;code&gt;FacesContext.getCurrentInstance().getExternalContext().redirect(ivy.html.taskstartref(ivy.wf.findTask(95)));&lt;/code&gt;&lt;/pre&gt;
The following code does not work as well (fails silently):&lt;pre&gt;&lt;code&gt;IHttpResponse resp = ivy.response as IHttpResponse;
resp.sendRedirect(ivy.html.taskstartref(in.task));&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We tried also:
&lt;/p&gt;&lt;pre&gt;&lt;code&gt;IHttpResponse resp = ivy.response as IHttpResponse;
HttpServletResponse sresp = resp.getHttpServletResponse();
sresp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
sresp.setHeader("Location",ivy.html.taskstartref(in.task));
sresp.sendRedirect(ivy.html.taskstartref(in.task));
sresp.flushBuffer();&lt;/code&gt;&lt;/pre&gt;
Here we get:&lt;br&gt;
IllegalStateException: Cannot change buffer size after data has been written&lt;br&gt;
Cannot set content type. Response already committed&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is there a possibility to achieve what we try to do?
Like for the process-start I have tried to find a proper IRequestHandler for starting a task. I have not found it.&lt;/p&gt;
&lt;p&gt;Thanks a lot in advance&lt;/p&gt;
&lt;p&gt;Emmanuel&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1383/how-to-dynamically-start-a-task-from-a-process-that-was-started-from-an-html-dialog" rel="self"></atom:link><language>en</language><lastBuildDate>Sun, 05 Jul 2015 22:39:18 -0400</lastBuildDate><item><title>Answer by Emmanuel</title><link>https://answers.axonivy.com/questions/1383/how-to-dynamically-start-a-task-from-a-process-that-was-started-from-an-html-dialog/1390</link><description>&lt;p&gt;Hello Flavio,&lt;/p&gt;
&lt;p&gt;Thanks for your help, so I post the solution for others here.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;in our HTML Dialog we trigger the process start with our ProcessStarter and pass the TaskId to start as parameter&lt;/li&gt;
&lt;li&gt;The process retrieves the task start url with &lt;code&gt;[out.redirectUrl = ivy.html.taskstartref(in.task);]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;At the end of the process there is an End Page that points to a "redirect-end-page.jsp" using this redirectUrl for redirecting the user automatically to the Task.
(&lt;code&gt;document.location.href='&amp;lt;%=redirectTask%&amp;gt;'&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Thanks again Flavio!&lt;/p&gt;
&lt;p&gt;Emmanuel&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Emmanuel</dc:creator><pubDate>Sun, 05 Jul 2015 22:39:18 -0400</pubDate><guid>https://answers.axonivy.com/questions/1383/how-to-dynamically-start-a-task-from-a-process-that-was-started-from-an-html-dialog/1390</guid></item></channel></rss>