Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: edited the attributes of <make-value> because the map is optional (seen in different minilang scripts in OFBiz)
Alert
titleMini Lang Deprecated
typeWarning

According to the proposal thread in [1] we decided to deprecate mini lang. For additional information please refer to the corresponding issue [2].


[1] https://s.apache.org/iS8W

[2]

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyOFBIZ-9350

Current Mini Language (minilang) Reference Guide (Version 3)

Mini-language Reference

The Apache Open For Business Project

Note

This is a draft document. It can be modified at any time by any committer. Comments on the draft should be made on the dev mailing list.

Grammar version 2 (http://ofbiz.apache.org/dtds/simple-methods-v2.xsd

...

)

...

Info

...

titleOlder versions

There are 2 older versions that you can find respectively at

Mini-Language Guide (Version 1 - Deprecated)

Mini-Language Guide (Version 2 - Deprecated)

 

Attributes

Attribute Types

Type

Description

Type

Description

Example

constant

A string constant. The string may not include an expression.

name="fooMethod"

constant+expr

A string constant. The string may include an expression, but an expression-only string is not allowed.

default="${foo}Method"

expression

A UEL expression without enclosing brackets.

from="item.quantity * item.priceEach"

${expression}

A UEL expression with enclosing brackets.

default="${parameters.itemId}"

script

A short script ("scriptlet").

script="groovy:foo.bar();"

 

The <simple-method> element

Section
Column
width20%
<simple-method>
Column
Contains a block of code.

A simple method can be called in either an event context from the Control
Servlet (or another event) or in a service context through the Service
Engine, or any other component that has access to a service dispatcher.

Code Block
xml
xml

<simple-method method-name="fooMethod">
  <!-- some mini-language code goes here -->
</simple-method>
Attributes

Name

Type

Requirements

Description

Note

method-nameoptional

constant

required

A name (preferably a legal Java identifier) for this method.

Each simple method in a file must have a unique name.

short-description

constant

optional

A short description of the method.

Used for documentation.

default-error-code

optional

 

default-success-code

optional

 

login-required

constant

optional

Require a user login to run this method.

Defaults to "true".

use-transaction

constant

optional

Create a transaction if none exists for this thread.

Defaults to "true".

default-error-code

constant

optional

The default error return code.

Defaults to "error".

default-success-code

constant

optional

The default success return code.

Defaults to "success".

parameter-map-name

optional

 

event-request-object-name

constant

optional 

The name of the field containing the javax.servlet.ServletRequest object.

Defaults to "request".

event-sessionresponse-object-name

constant

optional 

The name of the field containing the javax.servlet.ServletResponse object.

Defaults to "response".

event-responsesession-object-name

constant

optional

 

The name of the field containing the javax.servlet.http.HttpSession object.

Defaults to "session".

event-response-code-name

constant

optional 

The name of the field containing the event response code.

Defaults to "_response_code_".

event-error-message-name

optional

constant

optional

The name of the field containing the event error message.

Defaults to "_error_message_". 

event-error-message-list-name

constant

optional 

The name of the field containing the event message list.

Defaults to "_error_message_list_".

event-event-message-name

constant

optional 

The name of the field containing the event message.

Defaults to "_event_message_".

event-event-message-list-name

constant

optional

 

The name of the field containing the event message list.

Defaults to "_event_message_list_".

service-response-message-name

constant

optional

The name of the field containing the service response message.

Defaults to "responseMessage".

service-response-message-name

optional

 

service-error-message-name

constant

optional 

The name of the field containing the service error message.

Defaults to "errorMessage".

service-error-message-list-name

constant

optional 

The name of the field containing the service error message list.

Defaults to "errorMessageList".

service-error-message-map-name

constant

optional 

The name of the field containing the service error message map.

Defaults to "errorMessageMap".

service-success-message-name

constant

optional 

The name of the field containing the service success message.

Defaults to "successMessage".

service-success-message-list-name

constant

optional

 

login-required

optional

 

use-transaction

optional

 

locale-name

optional

 

delegator-name

optional

 

security-name

optional

 

dispatcher-name

optional

 

user-login-name

optional

 

Info
titleProposed Changes
  • Eliminate unused and seldom used attributes.
  • Currently, the method-name attribute is optional. Require the method-name attribute.

Assignment Operations

The name of the field containing the service success message list.

Defaults to "successMessageList".

 

Child Elements

Name

Requirements

 

(Any block of code)

optional

 

 

Assignment Operations

Assignment operations modify the script's state.

Section
Column
width20%
<add-error>
Currently, child elements are optional. Require one child element.

One of the following child elements is required:

Column
Adds a message to the error message list.
Code Block
xml
xml

<add-error>
  <fail-message message="There was an error" />
</add-error>
Attributes

Name

Type

Requirements

Description

Note

error-list-name

constant

optional

The name of a list that will contain the message.

Default is Defaults to "error_list".

 

Child Elements

<fail-message>

optional

<fail-property>

optional

Info
titleProposed Changes

Name

 

<fail-message>

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

<fail-property>

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

Section
Column
width20%
<clear
<alt-
field>
permission>
Removes a field from memory.

Attributes

Column
Code Block
xmlxml

<clear-field field="foo" />

field

optional

The name of the field to remove

map-name

optional

The name of the map to remove

Info
titleProposed Changes
  • Currently, the field attribute is optional. Require the field attribute.
  • Eliminate the map-name attribute.
Declares an alternate permission (<check-permission> sub-element).

Alternate permissions are checked when the primary permission check fails.

Attributes

Name

Type

Requirements

Description

Note

permission

constant, ${expression}

required

The permission to check.

 

action

constant, ${expression}

optional

The action to be performed (permission scope).

Examples: "_ADMIN", "_CREATE", "_UPDATE".

Section
Column
width20%
<create-object>
<assert>
Create a new Java object.

Attributes

Column
Code Block
xmlxml

<create-object field="foo" class-name="com.acme.FooClass">
  <string value="bar" />
  <field field="foo" />
</create-object>

field

optional

The name of the field for the new object

class-name

optional

The Java class name

Child Elements

<field>

optional

<string>

optional

Info
titleProposed Changes
  • Currently, both attributes are optional. Require both attributes.
  • Deprecate and replace with scriptlet
Adds an error message to the error message list for each condition that evaluates to false.
Attributes

Name

Type

Requirements

Description

Note

title

constant, ${expression}

optional

The title of the assert operation.

The title is used in test reports.

error-list-name

constant

optional

The name of a list that will contain the message.

Defaults to "error_list".

 

Child Elements

Name

 

Any <condition> child element

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

Section
Column
width20%
<fail
<check-
message>
id>
Declares a message to be added to a message list.

Attributes

Column
Code Block
xmlxml

<add-error>
  <fail-message message="There was an error" />
</add-error>

message

optional

The message text

Info
titleProposed Changes
  • Currently, the message attribute is optional. Require the message attribute.
Section
Evaluates the specified field, and adds an error message to the error message list if the field's value is not a valid data source ID value.

Valid IDs can be any sequence of characters or digits, but they must not contain the following characters: space [ ], double quote ["], single quote ['], ampersand [&], question mark [?], less-than sign [<]\, greater-than sign [>], forward-slash [/], back-slash [\ ].

Attributes

Name

Type

Requirements

Description

Note

field

expression

optional

The name of the field to test.

 

error-list-name

constant

optional

The name of a list that will contain the message.

Defaults to "error_list".

 

Child Elements

One of the following child elements is required:

Name

 

<fail-message>

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

<fail-property>

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

Column
width20%
<fail-property>

Attributes

Column
Declares a property key that is used to add a message to a message list.
Code Block
xmlxml

<add-error>
  <fail-property resource="ErrorMessages" property="FooError" />
</add-error>

resource

optional

Name of the resource where the message can be found

property

optional

The message property key

Info
titleProposed Changes
Currently, both attributes are optional. Require both attributes.

Section
Column
width20%
<field
<check-
to-list>
permission>
Copies a field to a list.

Attributes

Column
Code Block
xmlxml

<field-to-list list="barList" field="foo" />

list

optional

Name of the list. If the list does not exist, one is created.

field

optional

The field to add to the list

Info
titleProposed Changes
  • Currently, both attributes are optional. Require both attributes.
  • Deprecate and replace with UEL expression.
Section
Column
width20%
<field-to-request>
Column
Copies a field to a servlet request attribute.
Checks if the user has the specified permission, and adds an error message to the error message list if the user does not have the specified permission.

Note that this element must be followed by the <check-errors> element for it to do anything meaningful.

Attributes

Name

Type

Requirements

Description

Note

permission

constant, ${expression}

required

The permission to check.

 

action

constant, ${expression}

optional

The action to be performed (permission scope).

Examples: "_ADMIN", "_CREATE", "_UPDATE".

error-list-name

constant

optional

The name of a list that will contain the message.

Defaults to "error_list".

 

Child Elements

One or more of the following child element is optional:

Name

 

<alt-permission>

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

One of the following child elements is required:

Name

 

<fail-message>

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

<fail-property>

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

Attributes

Section
Column
width20%
<clear-field>
Column
Sets the value of the specified field to null.
Code Block
xml
xml
<clear-field field="foo"
Code Block
xmlxml

<field-to-request field="foo" request-name="fooAttribute" />

field

optional

The name of the field to copy from

request-name

optional

The name of the request attribute to copy to

map-name

optional

The name of the map containing field

Info
titleProposed Changes
  • Currently, all attributes are optional. Require the field and request-name attributes.
  • Eliminate the map-name attribute.
  • Deprecate and replace with a UEL expression.
Section
Column
width20%
<field-to-result>
Column
Copies a field to a service OUT attribute.
Code Block
xmlxml

<field-to-result field="foo" result-name="fooAttribute" />
Attributes

Name

Type

Requirements

Description

Note

field

expression

required

The name of the field to copy from, the source of the assignment

 

result-name

expression

optional

The name of the result field to set, the target of the assignment

Defaults to field

Note
titleDraft Status

Final draft.

remove.

 

Section
Column
width20%
<field
<create-
to-session>
Column
object>
Column
Creates an instance of the specified class.

The <string> and <field> sub-elements are passed to the constructor method as arguments in the order they are specified.
A runtime exception will be thrown if the sub-elements do not match the constructor method arguments

Copies a field to a servlet session attribute

.

Code Block
xml
xml

<field-to-session<create-object field="foo" sessionclass-name="com.acme.FooClass">
  <string value="bar" />
  <field field="fooAttributefoo" />
</create-object>
Attributes

Name

Type

Requirements

Description

Note

field

expression

optionalrequired

The name of the field to copy fromfor the new object.

 

classsession-name

constant

requiredoptional

The name of the session attribute to copy to

map-name

optional

The name of the map containing field

Java class name.

 

 

Child Elements

Name

Requirements

 

<field>

optional

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

<string>

optional

(?) (https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{}})

Warning

Deprecated - use the <script> element

Info
titleProposed Changes
  • Currently, all attributes are optional. Require the field and session-name attributes.
  • Eliminate the map-name attribute.
  • Deprecate and replace with a UEL expression

    .

    Section
    Column
    width20%
    <first
    <fail-
    from-list>
    message>
  • Currently, both attributes are optional. Require both attributes.
  • Column
    Declares an error message.
    Code Block
    xml
    xml
    <add-error>
      <fail-message message="There was an error.
    Copies the first element in a list to a field. If the list is empty or not found, sets the field to null.
    Code Block
    xmlxml
    
    <first-from-list entry-name="foo" list-name="fooList" />
    </add-error>
    
    Attributes
    entry-name

    Name

    optional

    The name of the field to copy to

    list-name

    optional

    The name of the list to copy from

    Info
    titleProposed Changes

    Type

    Requirements

    Description

    Note

    message

    constant+expr

    required

    The message text.

     

    Deprecate and replace with a UEL expression.

    Section
    Column
    width20%
    <list
    <fail-
    to-list>
    property>
    Column
    Copies list elements to another list. If the target list is not found, a new list is created
    Declares an error message found in a properties file.
    Code Block
    xml
    xml
    
    <list-to-list list-name="foo" to-list-name="fooList<add-error>
      <fail-property resource="ErrorMessages" property="FooError" />
    </add-error>
    
    Attributes

    Name

    Type

    Requirements

    Description

    Note

    resource

    constant

    required

    list-name

    optional

    The name of the list to copy from

    to-list-name

    optional

    The name of the list to copy to

    Info
    titleProposed Changes

    the resource where the message can be found.

     

    property

    constant

    required

    The message property key.

     

  • Currently, both attributes are optional. Require both attributes.
  • Rename the list-name attribute to from-field or from-list to make the syntax similar to other operators.

    Section
    Column
    width20%
    <map-to-map>
    <field>

    Attributes

    Column
    Declares an environment field to be passed as an argument to an object method call.
    Attributes

    Name

    Type

    Requirements

    Description

    Note

    field

    expression

    required

    Copies map entries to another map. If the target map is not found, a new map is created.
    Code Block
    xmlxml
    
    <map-to-map map-name="foo" to-map-name="fooMap" />
    

    map-name

    optional

    The name of the map to copy fromenvironment field to use.

     

    type

    constantto-map-name

    optional

    The name Java class of the map to copy to

    Info
    titleProposed Changes

    argument.

    Defaults to "java.lang.String"