You can use Groovy scripting language to prepare data for any presentation layer screen rendering tool, including the FreeMarker templating engine and OFBiz widgets.
Groovy has been integrated into the OFBiz framework, so using it is as simple as creating a text file with Groovy code and then pointing one or more Screen widget actions
declarations to the location of the Groovy file.
Note: a side effect of integration is that execution context information, including the HTTP/HTTPS request message and request parameters, are always available in the Groovy runtime context.
By convention, Groovy files are located in the webapp/WEB-INF/actions
directory of a containing Component. For example, we could have a Groovy file named myGroovyFile.groovy
located in the ~myComponent/webapp/WEB-INF/actions
directory.
To prepare "Groovy" data, follow these steps:
.groovy
suffix.Separating web page layout and style from data is the stuff Model-View-Controller (MVC) web application design patterns are made of. The OFBiz framework enables MVC separation through a number of architectural features, including the separation of web page screen (or "view") definitions from the data that is presented by the views. Web page views and screen layouts may be built using a variety of tools, including the OFBiz Screen widget, FreeMarker templates, and/or other OFBiz widgets.
All these tools support context aware, runtime merging of screen view definitions with data gathered and manipulated using the Groovy scripting language.
Groovy is a dynamic scripting language with syntax similar to Java and with many additional features "inspired" by languages such as Python, Ruby, and Smalltalk (http://groovy.codehouse.org). Some commonly used Groovy patterns found within the OFBiz code base are listed in the following table:
Usage |
Groovy code |
---|---|
Import statements |
|
To load request parameters from a Form or URL HTTP/HTTPS request |
|
Set request parameters into the context directly from a URL request |
|
Create a new Java List structure Check for an empty list |
|
Create an empty Java Map structure (key, value pairs) |
|
"Safe Navigation Operator" (Used to avoid |
|
"Elvis Operator" |
|
"For" loops |
|
18.224.73.175