How to enbed a variable into HTML label?

1,842 views
Skip to first unread message

york tipse

unread,
Mar 13, 2015, 12:47:45 AM3/13/15
to jbpm-...@googlegroups.com
The default source of a HTML label is "<p>HTML</p>" . Is there someone know how to embed a variable into it? For example, "<p>{myvariable}</p>"  would be replaced with "<p>Hello</p>" if  myvariable="Hello".
I tried "<p>{myvariable}</p>" but it doesn't work. It just shows {myvariable}.

Thanks.

-York 

Pere Fernandez

unread,
Mar 13, 2015, 4:37:16 AM3/13/15
to york tipse, jbpm-...@googlegroups.com
Hi York,

the HTML labels are for static content but there is something that you can do is make a text field be shown as a HTML text. To do that you can do:

1.- Add a text field
2.- Open it's  properties and select the "show as HTML" checkbox.
3.- Write  a formula to calculate the HTML code you want to show, for example ="<p>" + {field_name} + "</p>" where field_name is the name of the field you want to show it's value. You can create more complex formulas using standard java operators (+, -, *, / ...) like = "<b>Total: " + ({field1} + {field2}) + "</b>" 

Note that the Formula has to start with = and all the field names used on the formula should be surrounded by { }. 


--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-usage/245cbb67-3cae-4534-8d87-b7b81b049573%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

york tipse

unread,
Mar 13, 2015, 1:11:42 PM3/13/15
to jbpm-...@googlegroups.com, york...@gmail.com
Hi Pere,

Thank you very much for your help.
I want to know if a Script Task can change a process variable's value.  For example;

"Start" -> "Human Task1"  -> "Script Task1" -> "Human Task2" -> "End"

I have a process variable called "myvariable", I also have a text input named "myvariable" in 2 Human Tasks.

At first, "Human Task1": Actor set myvariable = "valA";
Then,  "Script Task1" : script set myvariable = "valB";


In  "Human Task2" , myvariable should be  "valB" but it's still "valA".

My question is: Why Script Task can't change process variable's value? Is there any other way to fix this issue?

Thanks.
York.

Kris Verlaenen

unread,
Mar 13, 2015, 4:55:18 PM3/13/15
to york tipse, jbpm-...@googlegroups.com
York,

On Fri, Mar 13, 2015 at 6:11 PM, york tipse <york...@gmail.com> wrote:
Hi Pere,

Thank you very much for your help.
I want to know if a Script Task can change a process variable's value.  For example;

"Start" -> "Human Task1"  -> "Script Task1" -> "Human Task2" -> "End"

I have a process variable called "myvariable", I also have a text input named "myvariable" in 2 Human Tasks.

At first, "Human Task1": Actor set myvariable = "valA";
Then,  "Script Task1" : script set myvariable = "valB";
How do you do this?  Note that a script has a local copy of a variable injected (at least for primitives, for mutable objects, you have a reference to the same object).  To change a value, you need to use kcontext.setVariable(name, value).

Kris

york tipse

unread,
Mar 16, 2015, 5:15:07 PM3/16/15
to jbpm-...@googlegroups.com, york...@gmail.com
Hi Kris,

Thank you very much for the help.
I still have that issue in 6.1.0:

myvariable is a process variable,

At first, "Human Task1": Actor set myvariable = "valA";
Then, in Script Task:  kcontext.setVariable("myvariable", "valB") .
but process variable myvariable is still "valA"; Of course kcontext.getVariable("myvariable") is "valB",

So, kcontext.setVariable("myvariable", "valB")  doesn't change the process variable myvariable's value.

I need to re-set process variable in Script Task.
Did I do something wrong?

Kris Verlaenen

unread,
Mar 16, 2015, 7:42:55 PM3/16/15
to york tipse, jbpm-...@googlegroups.com
On Mon, Mar 16, 2015 at 10:15 PM, york tipse <york...@gmail.com> wrote:
Hi Kris,

Thank you very much for the help.
I still have that issue in 6.1.0:
Could you possibly try 6.2.0.Final to check if it might be an issue that is already solved?

myvariable is a process variable,

At first, "Human Task1": Actor set myvariable = "valA";
Then, in Script Task:  kcontext.setVariable("myvariable", "valB") .
but process variable myvariable is still "valA"; Of course kcontext.getVariable("myvariable") is "valB",

So, kcontext.setVariable("myvariable", "valB")  doesn't change the process variable myvariable's value.

I need to re-set process variable in Script Task.
Did I do something wrong?

Could you share a process and Java test class that we could use to take a look at this?

Kris
 

york tipse

unread,
Mar 19, 2015, 11:31:32 PM3/19/15
to jbpm-...@googlegroups.com, york...@gmail.com
Hi Kris,

Fixed it by adding code in "On Entry Action" in "Human Task2":

On Entry Action: myvariable=(String)(kcontext.getVariable("myvariable") );

Do you know where is the java code for Document Field Type in 6.1.0?
We need to show the image in human task form if Actor uploaded an image file. Currently, Document Field Type only shows a small icon.
Maybe we can get it by overriding it's getShowHTML method.

Or do you know if there is any other easy way?

Thank you!

-York

Pere Fernandez

unread,
Mar 20, 2015, 4:35:33 AM3/20/15
to york tipse, jbpm-...@googlegroups.com
To do that I'd recommend you to create a custom field type to use it on the forms you want to show the image instead of the Document input. Look at look at http://docs.jboss.org/jbpm/v6.1/userguide/chap-formmodeler.html#sect-formmodeler-fieldTypes to see how to implement one. Basically you have to do the following:

To do that create a Java Project with dependencies to modules:

<dependency>
  <groupId>org.jbpm</groupId>
  <artifactId>jbpm-form-modeler-api</artifactId>
</dependency>
<dependency>
  <groupId>org.jbpm</groupId>
  <artifactId>jbpm-document</artifactId>
</dependency>

On your Custom Field Type you should implement the getShowHTML and getInputHTML in order to return the HTML that has to be shown on screen here is were you have to generate your img TAG with the value that you receive as a parameter. You should cast the received value to org.jbpm.document.Document and when you got it casted you can get the download Link using the getLink() method or also the content (byte[]) using the getContent() method.

Once you've done it, put your module in the server classpath and restart.

After that you should edit / create your form, add the document field you have to use and edit it's properties, on the Field Type combo choose Custom Field, the properties form will change and a combo with all the available custom types will appear so you could select yours. 

Hope it helps,

Pere

Reply all
Reply to author
Forward
Message has been deleted
0 new messages