How to dynamically start a task from a process that was started from an HTML Dialog
Hi all,
In a JSF Dialog we can start a task dynamically with: <pre<code>FacesContext.getCurrentInstance().getExternalContext().redirect(ivy.html.taskstartref(ivy.wf.findTask(95)));</code></pre><pre><code>FacesContext.getCurrentInstance().getExternalContext().redirect(ivy.html.taskstartref(ivy.wf.findTask(95)));</code></pre>
We can also start an IProcess dynamically with something like that:
<pre><code>IRequest request = requestFactory.createRequest(processStart, thisMapOrEmptyMapIfNull(params));
IResponse response = responseFactory.createResponse();
IRequestHandler requestHandler = (IRequestHandler)processStart.getProcessModelVersion().getAdapter(IProcessEngine.class);
requestHandler.handleRequest(request, response);
</code></pre>
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.<br />
In the started process, as we are not in the JSF context, the following does not work (fails silently):<pre><code>FacesContext.getCurrentInstance().getExternalContext().redirect(ivy.html.taskstartref(ivy.wf.findTask(95)));</code></pre>
The following code does not work as well (fails silently):<pre><code>IHttpResponse resp = ivy.response as IHttpResponse;
resp.sendRedirect(ivy.html.taskstartref(in.task));</code></pre>
We tried also:
<pre><code>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();</code></pre>
Here we get:<br />
IllegalStateException: Cannot change buffer size after data has been written<br />
Cannot set content type. Response already committed
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.
Thanks a lot in advance
Emmanuel