Hello,
After starting a workflow I populate ArrayList<String> in the TaskLsitener and i want to show its content in the workflow's tasks. How can i achieve that?
Freemarker supports arrays so creating an ftl shouldn't be a problem.
I can create variable of type "d:any" in the model, pass the value in the TaskListener but how to can retrive that values in the Freemarker template ?
So far I have created:
TaskListener:
List<String> myArray = new ArrayList<>(); // ..... (populating the array) ((ExecutionEntity)delegateTask.getExecution()).getProcessInstance().setVariable("my_myDataTest",myArray);
Model:
<property name="my:myDataTest"> <type>d:any</type> <mandatory>false</mandatory> </property>
Template:
<div id="${fieldHtmlId}-buttons"></div> <#list field.value as item> <b> ${item} </b>
</#list> </div>
I tried that but I'm getting an error.
my-project | 2020-04-09 20:18:57,721 ERROR [freemarker.runtime] [http-nio-8080-exec-3] Error executing FreeMarker template my-project | FreeMarker template error: my-project | For "#list" list source: Expected a collection or sequence, but this evaluated to a string (wrapper: f.t.SimpleScalar): my-project | ==> field.value [in template "com/epmflow/my-data-test.ftl" at line 7, column 10]
my-project | The failing instruction (FTL stack trace): my-project | ---------- my-project | ==> #list field.value as city [in template "com/epmflow/my-data-test.ftl" at line 7, column 3] my-project | #include "\${field.control.template}" [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderField" at line 91, column 7] my-project | @renderField field=form.fields[item.id] [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 122, column 13] my-project | #else [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 121, column 10] my-project | #else [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 117, column 4] my-project | @formLib.renderSet set=item [in template "org/alfresco/components/form/form.get.html.ftl" at line 39, column 28] my-project | #if item.kind == "set" [in template "org/alfresco/components/form/form.get.html.ftl" at line 37, column 22] my-project | #nested [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderFormContainer" at line 64, column 10] my-project | @formLib.renderFormContainer formId=f... [in template "org/alfresco/components/form/form.get.html.ftl" at line 35, column 16] my-project | #else [in template "org/alfresco/components/form/form.get.html.ftl" at line 30, column 13] my-project | #elseif form?exists [in template "org/alfresco/components/form/form.get.html.ftl" at line 20, column 10] my-project | @uniqueIdDiv [in template "org/alfresco/components/form/form.get.html.ftl" at line 15, column 7] my-project | @markup id="html" [in template "org/alfresco/components/form/form.get.html.ftl" at line 14, column 4] my-project | @standalone [in template "org/alfresco/components/form/form.get.html.ftl" at line 1, column 1] my-project | ----------
When i use api-explorer, i can get the value (it's not a string)
{ "entry": { "name": "my_myDataTest", "type": "d:any", "value": [ "one", "two", "three", "four" ] }
EDIT. I checked that the value is passed as a string "one,two,three,four". I can of couse split it by "," but then i could not use commas in the array. Is there a better way?
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.