Passing Screen widget parameters to FreeMarker

It is possible to pass context information, such as the name of a screen, to a FreeMarker template and/or a Groovy script directly from the Screen widget definition.

How to do it...

Context information can be passed to FreeMarker in the following way:

  1. Under the actions element within a Screen widget definition, add one/more set elements with the field attribute set to the name of the variable and the value attribute set to the value of the variable.
  2. Retrieve this variable using the name specified in step 1.

How it works

Setting field values using the earlier method places the named variable with its value within the execution context. Once in the context, the FreeMarker rendering engine and any other screen rendering artifact, including any OFBiz widget, has access to it.

There's more

For example, to add an action to set a context variable named myScreenVariable, you might code something like the following:

<actions>
<set field="myScreenVariable" value="aValue">
</actions>

Within FreeMarker, you may access this value as follows:

<#assign localVariable = myScreenVariable>

To retrieve this value using Groovy:

localScreenName = context.myScreenVariable;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.174.23