...
The transaction-rollback tag will rollback a transaction if a transaction was begun in the current demarcation context as represented by the environment field named as the began-transaction-name. If the Boolean in that field is false a set rollback only will operation will be done instead of rollback which will force the transaction to rollback regardless of which method or object is responsible for beginning and ending the transaction.
Attribute Name | Required? | Description |
---|---|---|
began-transaction-name | N | The name of the method environment field that contains a Boolean specifying whether or not a transaction was begun in the current transaction demarcation. Defaults to "beganTransaction". |
Conditional (If) Operations
if
The if
operation offers a flexible way of specifying combinations of conditions, alternate conditions, and operations to run on true evaluation of the conditions or to run otherwise.
The other if operations are meant for a specific, simple condition when used outside of the condition sub-element of this operation. The attributes of the other if operations are the same when used inside this operation. In this case they are empty tags and do not have any sub-elements because the operations to run are under the then
or else
tags.
Sub-Element Name | How Many | Description |
---|---|---|
condition | 1 | A simple element with no attributes that contains the condition that will be evaluated to determine which sub-operations to execute. To combine the other if operations documented below the and , or , xor , and not elements can be used. The and, or, and xor elements can contain as many general if operations and modifier/combination elements (ie and, or, xor, and not). |
then | 1 | The then element is used to contain operations that will run if the condition evaluate to true. A then tag must be included, but can be empty. |
else-if | 0 to many | The else-if element can be used to specify alternate conditional execution blocks. Each else-if element must contain two sub-elements: condition and then . These operations are used the same as the condition and then elements describes above. If the condition of the parent if element is evaluated to false, each condition of the else-if sub-elements will be evaluated, and the operations under the then element corresponding first condition that evaluates to true will be run. |
else | 0 or 1 | The else element can be used to contain operations that will run if the condition evaluates to false, and if no else-if sub-conditions evaluate to true. It can contain any simple-method operation. The else tag must be placed as the last tag under the if tag. |
if-validate-method
The operations contained by the if-validate-method tag will only be executed if the validate method returns true. This tag can contain any of the simple-method operations, including the conditional/if operations.
Attribute Name | Required? | Description |
---|---|---|
map-name | N | The name of the method environment field that contains the map that the field to be validated will come from. If not specified the field-name will be treated as a method environment field name (an env-name). |
field-name | Y | The name of the map field that will be validated. |
method | Y | The name of the method that will be called to validate the field. It must be a static method that takes a single String parameter and return a boolean. |
class | N | The name of the class that contains the validation method. If not specified defaults to "org.ofbiz.base.util.UtilValidate". |
Sub-Element Name | How Many | Description |
---|---|---|
Any Operation | 0 to many | Any simple-method operation can be nested under an if-* tag. |
else | 0 or 1 | The else tag can be used to contain operations that will run if the condition fails, or in other words if the operations under the if tag do not run. It can contain any simple-method operation. The else tag must be placed as the last tag under the if-* tag. |
if-compare
The operations contained by the if-compare tag will only be executed if the comparison returns true. This tag can contain any of the simple-method operations, including the conditional/if operations.
Attribute Name | Required? | Description |
---|---|---|
map-name | N | The name of the method environment field that contains the map that the field to be validated will come from. If not specified the field-name will be treated as a method environment field name (an env-name). |
field-name | Y | The name of the map field that will be compared. |
operator | Y | Specified the comparison operator must be one of the following: less, greater, less-equals, greater-equals, equals, not-equals, or contains. |
value | Y | The value that the field will compared to. Must be a String, but can be converted to other types. |
type | N | The data type to use for the comparison. Must be one of the following: String, Double, Float, Long, Integer, Date, Time, or Timestamp. If no type is specified the default will be String. |
format | N | A format specifier to use when converting String objects to other data types, mainly Date, Time and Timestamp. |
Sub-Element Name | How Many | Description |
---|---|---|
Any Operation | 0 to many | Any simple-method operation can be nested under an if-* tag. |
else | 0 or 1 | The else tag can be used to contain operations that will run if the condition fails, or in other words if the operations under the if tag do not run. It can contain any simple-method operation. The else tag must be placed as the last tag under the if-* tag. |
if-compare-field
The operations contained by the if-compare-field tag will only be executed if the comparison returns true. This tag can contain any of the simple-method operations, including the conditional/if operations.
Attribute Name | Required? | Description |
---|---|---|
map-name | N | The name of the method environment field that contains the map that the field to be validated will come from. If not specified the field-name will be treated as a method environment field name (an env-name). |
field-name | Y | The name of the map field that will be compared. |
operator | Y | Specified the comparison operator must be one of the following: less, greater, less-equals, greater-equals, equals, not-equals, or contains. |
to-map-name | N | The name of the method environment field that contains the map that the field to be compared will come from. If left empty will default to the method environment. It does not default to the map-name because that would make it impossible to compare a map field to an environment field. |
to-field-name | N | The name of the to-map field that the main field will be compared to. If left empty will default to the field-name. |
type | N | The data type to use for the comparison. Must be one of the following: String, Double, Float, Long, Integer, Date, Time, or Timestamp. If no type is specified the default will be String. |
format | N | A format specifier to use when converting String objects to other data types, mainly Date, Time and Timestam |
Sub-Element Name | How Many | Description |
---|---|---|
Any Operation | 0 to many | Any simple-method operation can be nested under an if-* tag. |
else | 0 or 1 | The else tag can be used to contain operations that will run if the condition fails, or in other words if the operations under the if tag do not run. It can contain any simple-method operation. The else tag must be placed as the last tag under the if-* tag. |
if-regexp
The operations contained by the if-regexp tag will only be executed if the value complies with the regular expression. This tag can contain any of the simple-method operations, including the conditional/if operations.
Attribute Name | Required? | Description |
---|---|---|
map-name | N | The name of the method environment field that contains the map that the field to be validated will come from. If not specified the field-name will be treated as a method environment field name (an env-name). |
field-name | Y | The name of the map field that will be compared. |
expr | Y | A regular expression that the map value must comply with. |
Sub-Element Name | How Many | Description |
---|---|---|
Any Operation | 0 to many | Any simple-method operation can be nested under an if-* tag. |
else | 0 or 1 | The else tag can be used to contain operations that will run if the condition fails, or in other words if the operations under the if tag do not run. It can contain any simple-method operation. The else tag must be placed as the last tag under the if-* tag. |
if-empty
The operations contained by the if-empty tag will only be executed if the map field is empty. This tag can contain any of the simple-method operations, including the conditional/if operations.
Attribute Name | Required? | Description |
---|---|---|
map-name | N | The name of the method environment field that contains the map that the field to be validated will come from. If not specified the field-name will be treated as a method environment field name (an env-name). |
field-name | Y | The name of the map field that will be compared. |
Sub-Element Name | How Many | Description |
---|---|---|
Any Operation | 0 to many | Any simple-method operation can be nested under an if-* tag. |
else | 0 or 1 | The else tag can be used to contain operations that will run if the condition fails, or in other words if the operations under the if tag do not run. It can contain any simple-method operation. The else tag must be placed as the last tag under the if-* tag. |
if-not-empty
The operations contained by the if-not-empty tag will only be executed if the map field is not empty. This tag can contain any of the simple-method operations, including the conditional/if operations.