Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To specify the XMLschema for a simple-methods or simple-map-processors XML file use the following:

Code Block
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="[to be modified www.ofbiz.org/dtds/simple-methods.xsd]">

...

The path or location for a Simple Method is the classpath and filename of the XML file.

In this Mini-Language you can invoke Simple Map Processors, Services and bsh scripts, perform entity related operations, and create messages to return to the caller. Specific operations can be enclosed in if blocks to execute conditionally and values or fields can be copied around in the maps, lists and method environment.
There are a number of tags which can be used to get and set attributes to/from a request or session object when called as an event or to set attributes in the result when called as a service. These operations are only applied when applicable. In other words if you include an env-to-request operation it will only be invoked when the simple-method is called as an event and an env-to-result operation will only be invoked when the simple-method is called as a service. Everything else is the same when called as an event or a service which makes it easy to write flexible logic that can be mounted/applied in various ways.
There are a number of objects that exist in the method environment when a simple-method starts or that are used as it executes to keep track of certain information. Some will exist when called as an event or a service, these are marked in the XSD. Each name can be overridden using an attribute on the simple-method tag. The defaults are listed below in the XSD.

Panel

(info) NOTE: The reference information for simple-method has been moved to annotations in

Wiki Markup
\[to be modified
www.ofbiz.org/dtds/simple-methods.xsd]
We hope to recommended soon a tool that will use XSL/Transform to render the documentation directly from the XSD file in Browsers



...

field-to-request
field-to-session
request-to-field
request-parameters-to-list
session-to-field
webapp-property-to-field

The webapp-property-to-field tag copies a property value from a properties file in a ServletContext resource to a field.

The tag is only used when the simple-method is called as an event, it is ignored otherwise (except the default value, if specified).

Attribute Name

Required?

Description

resource

Y

The resource location of the properties file inside the webapp, and relative to the root of the webapp (can be inside a war file). An example of this is "/WEB-INF/myprops.properties".

property

Y

The property whose value will be put in the field.

default

N

A default value to use if the property value is null or empty. This will also be used when NOT running as an event.

map-name

N

The name of the map in the method environment. If not specified the field-name will be used to set the field in the method environment.

field-name

Y

The name (key) of the map field to use.

Service Specific Operations

field-to-result

The field-to-result tag copies a field from a map to the specified service result field.

The tag is only used when the simple-method is called as a service, it is ignored otherwise.

Attribute Name

Required?

Description

map-name

N

The name of the map in the method environment. If not specified the field-name will be used to get the field from the method environment.

field-name

Y

The name (key) of the map field to use.

result-name

N

The name of the request attribute to use. Defaults to the field-name.

Method Environment Operations

map-to-map

The map-to-map tag copies all fields from one map to another map.

Attribute Name

Required?

Description

map-name

Y

The name of the map in the method environment the fields will come from.

to-map-name

N

The name of the map in the method environment the fields will go to. If empty the fields will be copied to the environment.

field-to-list

The field-to-list tag appends a field to the specified list.

Attribute Name

Required?

Description

map-name

N

The name of the map in the method environment. If not specified the field-name will be used to get the field from the method environment.

field-name

Y

The name (key) of the map field to use.

list-name

Y

The name of the list in the method environment that the object will be appended to.

to-string

The to-string tag converts the Object in the specified field to a String, putting the string in the same field.

Attribute Name

Required?

Description

map-name

N

The name of the map in the method environment. If not specified the field-name will be used to get the field from the method environment.

field-name

Y

The name (key) of the map field to use.

clear-field

The clear-field tag clears/removes the specified field.

Attribute Name

Required?

Description

map-name

N

The name of the map in the method environment. If not specified the field-name will be used to get the field from the method environment.

field-name

Y

The name (key) of the map field to use.

iterate

The operations contained by the iterate tag will be executed for each of the entries in the list, and will make the current entry available in the method environment by the entry-name specified. This tag can contain any of the simple-method operations, including the conditional/if operations.

Attribute Name

Required?

Description

entry-name

Y

The name of the method environment field that will contain each entry as we iterate through the list.

list-name

Y

The name of the method environment field that contains the list to iterate over.

Sub-Element Name

How Many

Description

Any Operation

0 to many

Any simple-method operation can be nested under the iterate tag.

first-from-list

The first-from-list tag will get the first entry from the given list and put it in the environment field with the given entry-name.

...

Attribute Name

...

Required?

...

Description

...

entry-name

...

Y

...

The name of the method environment field that will contain the first entry in the list.

...

list-name

...

Y

...

Service Specific Operations

field-to-result

...

Method Environment Operations

map-to-map
field-to-list
to-string
clear-field

Wiki Markup
*\[All operations in red have been be replaced by set operation\] *

field-to-field (deprecated, do not use)
env-to-env (deprecated, do not use)
env-to-field (deprecated, do not use)
field-to-env (deprecated, do not use)
string-to-field (deprecated, do not use)

...

Control Operations

iterate
first-from-list

----

Entity Engine Misc. Operations
now-timestamp-to-env

The now-timestamp-to-env tag creates a java.sql.Timestamp object with the current date and time in it and puts it in a field in the method environment.

...

Attribute Name

...

Required?

...

Description

env

...

Y

...


now-date-to-env

The now-date-to-env tag creates a java.sql.Date object with the current date in it and puts it in a field in the method environment.

...