The XPRESS language is an XML-based expression and scripting language. Statements written in this language, called expressions, are used throughout Waveset to add data transformation capabilities to forms and to incorporate state transition logic within Waveset objects such as Workflow and forms.
XPRESS is a functional language that uses syntax based on XML. Every statement in the language is a function call that takes zero or more arguments and returns a value. Built-in functions are provided, and you can also define new functions. XPRESS also supports the invocation of methods on any Java class and the evaluation of Javascript within an expression.
For a comprehensive discussion of XPRESS features, see Chapter 5, XPRESS Language
Expressions are used primarily for the following Waveset tasks:
Customizing the end-user and administrator forms. Forms use XPRESS to control the visibility of fields and to transform the data to be displayed and saved.
Defining flow of control in Workflow. Workflow uses XPRESS to define transition conditions, which determine the order in which steps in the workflow process are performed.
Implementing workflow actions. Workflow actions can be implemented using XPRESS. Action expressions can perform simple calculations, or call out to Java classes or JavaScript to perform a complex operation.
The expressions contained in these elements can be used throughout Waveset.
In the following example, the <add> element represents a call to the XPRESS function named add.
<add> <ref>counter</ref> <i>10</i> </add>
This function is passed two arguments:
first argument– value is determined by calling a function named ref. The argument to the ref function is a literal string that is assumed to be the name of a variable. The value returned by the ref function is the current value of the variable counter.
second argument -- value is determined by calling a function named i. The argument to the i function is a literal string that is an integer. The value that the i function returns is the integer 10.
The value returned by the add function will then be the result of adding the integer 10 to the current value of the variable counter. Every function call returns a value for the next operation to use. For example, if the ref call returns the value of the counter, then the <i> call returns the integer 10, then the <add> call returns the addition of the two calls.
The following example shows the use of XPRESS logic embedded within an Waveset form. XPRESS is used to invoke one of the FormUtil Java methods that will produce the relevant role-related choices for display in the browser. Note that the expression is surrounded by the <expression> tag.
<Field name=’waveset.role’> <Display class=’Select’ action=’true’> <Property name=’title’ value=’Role’/> <Property name=’nullLabel’ value=’None’/> <Property name=’allowedValues’> <expression> <invoke class=’com.waveset.ui.FormUtil’ name=’getRoles’> <ref>:display.session</ref> <ref>waveset.original.role</ref> </invoke> </expression> </Property> </Display> </Field>