Hi all,

In a JSF Dialog we can start a task dynamically with:

FacesContext.getCurrentInstance().getExternalContext().redirect(ivy.html.taskstartref(ivy.wf.findTask(95)));

We can also start an IProcess dynamically with something like that:

IRequest request = requestFactory.createRequest(processStart, thisMapOrEmptyMapIfNull(params)); 
IResponse response = responseFactory.createResponse(); 
IRequestHandler requestHandler = (IRequestHandler)processStart.getProcessModelVersion().getAdapter(IProcessEngine.class); 
requestHandler.handleRequest(request, response);

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.
In the started process, as we are not in the JSF context, the following does not work (fails silently):

FacesContext.getCurrentInstance().getExternalContext().redirect(ivy.html.taskstartref(ivy.wf.findTask(95)));
The following code does not work as well (fails silently):
IHttpResponse resp = ivy.response as IHttpResponse;
resp.sendRedirect(ivy.html.taskstartref(in.task));

We tried also:

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();
Here we get:
IllegalStateException: Cannot change buffer size after data has been written
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

asked 25.06.2015 at 23:25

Emmanuel's gravatar image

Emmanuel
(suspended)
accept rate: 66%

edited 25.06.2015 at 23:25

Hello Emmanuel, could you describe your use case? Basically I would suggest to use an End Page to forward a workflow/client to the next process.

(26.06.2015 at 14:49) Flavio Sadeghi ♦♦ Flavio%20Sadeghi's gravatar image

Hello Flavio,

Sorry for that long and not very "understandable" question ;) To make it short: is there a way to start a Task programmatically in such a situation: 1. The User clicks on a Displayed Task (HTML Dialog - JSF). 2. This triggers a Process Start dynamically, which gets as parameter the selected TaskId. 3. In this process we can find the Task with the TaskId and we would like to start it and display it to the user. As the Task is started in a Process that is not part of the HTML-JSF Dialog Logic, using "redirect" techniques described in the question do not work. Any Idea?

Cheers

(29.06.2015 at 13:27) Emmanuel Emmanuel's gravatar image

@Emmanuel: Why you can't use an End-Page for the redirect? The End Page does end the current running process and task properly. With a redirect in the middle of a process, the process is interrupted unexpected which (could) cause in unexpected behaviour/errors.

(01.07.2015 at 11:24) Flavio Sadeghi ♦♦ Flavio%20Sadeghi's gravatar image

Hello Flavio,

Thanks for your help, so I post the solution for others here.

  1. in our HTML Dialog we trigger the process start with our ProcessStarter and pass the TaskId to start as parameter
  2. The process retrieves the task start url with [out.redirectUrl = ivy.html.taskstartref(in.task);]
  3. 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. (document.location.href='<%=redirectTask%>')

Thanks again Flavio!

Emmanuel

link

answered 05.07.2015 at 22:39

Emmanuel's gravatar image

Emmanuel
(suspended)
accept rate: 66%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×68

Asked: 25.06.2015 at 23:25

Seen: 2,569 times

Last updated: 05.07.2015 at 22:39