2 Replies Latest reply on Oct 30, 2013 2:27 AM by swiderski.maciej

    FormProviderServiceImpl.getFormDisplayTask (jbpm6)


      I'm having problems with rendering forms from a human task.


      I'm calling org.jbpm.kie.services.api.FormProviderService.getFormDisplayTask(long taskId) to retrieve the rendered form. This results in a call to org.jbpm.kie.services.impl.form.FormProviderServiceImpl.getFormDisplayTask(long taskId) which finds the form template, sets up a map of the variables from the workflow instance and calls the freemarker rendering code to do the substitutions into the template.


      I can't see where the input mappings are resolved in that method. It iterates through the output parameters and includes those in the map but not the input parameters. Of course the values for the output mappings are not useful for rendering the form and seem to always be null (which makes sense to me).


      Have I got the terms input and output backwards? Is "Input" the values from the workflow instance sent to the task manager or is it the values returned from the task manager to the workflow instance? (and visa-versa for output?)

        • 1. Re: FormProviderServiceImpl.getFormDisplayTask (jbpm6)

          Found it.


          The code in FormProviderServiceImpl calls TaskData.getDocumentContentId() and then Context.getContentById(id) to retrieve the input mappings (similarly using TaskData.getOutputContemtId() for the output values).


          I'm curious about why there isn't a function available on the external API to get the input and output variables for a human task. The following code seems to be how you can do it but it is clumsy and uses APIs from the org.kie.internal... packages which I would have thought would be a bad thing to do.


          Task t = taskService.getTaskById(tid);
          ContentMarshallerContext context = contentService.getMarshallerContext(t);
          long inputId = t.getTaskData().getDocumentContentId();
          Content content = contentService.getContentById(inputId);
          Object input = ContentMarshallerHelper.unmarshall(content.getContent(), context.getEnvironment(), context.getClassloader());
          long outputId = t.getTaskData().getOutputContentId();
          content = contentService.getContentById(outputId);
          Object output = ContentMarshallerHelper.unmarshall(content.getContent(), context.getEnvironment(), context.getClassloader());


          So, is the above the correct way to get the task input and output parameters?

          1 of 1 people found this helpful
          • 2. Re: FormProviderServiceImpl.getFormDisplayTask (jbpm6)

            yes, that is correct way to do so.


            However using internal api (especially this from org.kie.internal) does not have to be bad practice. It's part of the internal API because it requires some additional time to settle before being promoted to public API. What is always welcome is feedback from community about missing or vague options in the API that might get improved.