Use of Enum in ServiceTask Expression

833 views
Skip to first unread message

carsten...@gmail.com

unread,
May 29, 2013, 4:34:49 AM5/29/13
to camunda-...@googlegroups.com
I have some ServiceTasks that are define as an Expression (Spring) in the process diagram


Example:
<serviceTask id="doSomethins" activiti:expression="#{servicesAdapter.update(id,"5")}" name="Do it">

Is it possible to user an Java Enum instead of String.

Example:

<serviceTask id="doSomethins" activiti:expression="#{servicesAdapter.update(id,Enum.STATE_5)}" name="Do it">


Or some other ideas to get of the Strings and have some constants ?

Daniel Meyer

unread,
May 31, 2013, 2:36:49 AM5/31/13
to camunda-...@googlegroups.com, carsten...@gmail.com
Hi Carsten,


Interesting question. I had to look it up:

According to the Java UEL docs (http://docs.oracle.com/javaee/5/tutorial/doc/bnahq.html), you can use the string representation of the enum constant value:

This means that in your example, instead of writing MyEnum.STATE_5 you can just write "STATE_5":
<serviceTask id="doSomething" activiti:expression="#{servicesAdapter.update(id,"STATE_5")}" name="Do it">

Since the class named "servicesAdapter" accepts a parameter for type MyEnum, the string is automatically converted to the corresponding enum constant value.

Cheers,

Daniel Meyer

Reply all
Reply to author
Forward
0 new messages