此内容没有您所选择的语言版本。

Chapter 7. Action scripts


Action scripts are pieces of code that define the Script property or the interceptor action of an element. Action scripts can access the global variables, process variables, and predefined variable kcontext. kcontext is an instance of the ProcessContext interface. For more information about kcontext variable, see the ProcessContext Javadoc.

Java and MVEL are supported as dialects for action script definitions. MVEL accepts valid Java code and additionally provides support for nested access to parameters. For example, the MVEL call person.name is equivalent of Java call person.getName().

Example action script in Java and MVEL dialects

// Java dialect
System.out.println(person.getName());

// MVEL dialect
System.out.println(person.name);
Copy to Clipboard Toggle word wrap

You can also use action scripts to view information about process instances. For example, use the following commands to:

  • Return the ID of a process instance:

    System.out.println(kcontext.getProcessInstance().getId());
    Copy to Clipboard Toggle word wrap
  • Return the parent process instance ID if a process instance has a parent:

    System.out.println(kcontext.getProcessInstance().getParentProcessInstanceId());
    Copy to Clipboard Toggle word wrap
  • Return the ID of a process definition related to a process instance:

    System.out.println(kcontext.getProcessInstance().getProcessId());
    Copy to Clipboard Toggle word wrap
  • Return the name of a process definition related to a process instance:

    System.out.println(kcontext.getProcessInstance().getProcessName());
    Copy to Clipboard Toggle word wrap
  • Return the state of a process instance:

    System.out.println(kcontext.getProcessInstance().getState());
    Copy to Clipboard Toggle word wrap

To set a process variable in an action script, use kcontext.setVariable("VARIABLE_NAME", "VALUE").

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat