Using data from a database or other source to build portions of your web page dynamically enables efficient and effective web page creation by freeing the screen's author from hardcoding values. To give widgets access to data sources and allow data preparation tools to fetch required input data, widget definitions include an actions
element. Within the actions
element, you may include directives to:
Some initial preparation has to be done to add new actions, as follows:
actions
element defined, add one.Actions can be added by the following steps:
actions
element. Each action is either a directive instructing OFBiz to gather data directly and place that data in the screen's context, or a file location pointer to a script file. actions
element with an end tag (</actions>
).The OFBiz screen handler invokes the actions
declarations (in the order presented) to prepare data for merger with widgets
declarations.
To get Java properties file resources, add a directive similar to the following within the actions
element of your widget definition:
<property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
To call a Groovy script, add an actions
directive similar to the following:
<script location= "component://myComponent/webapp/WEB-INF/actions/aGroovyScript.groovy" />
To make database calls directly from within a Screen widget's actions
element, use the following actions
element example—taken from the content Component's Screen widget definition for the Showforum
screen—as your guide:
<actions> <entity-condition list="forumMessages" entity-name="ContentAssocViewTo"> <condition-list combine="and"> <condition-expr field-name="contentIdStart" from-field="parameters.forumId"/> <condition-list combine="or"> <condition-expr field-name="caContentAssocTypeId" value="PUBLISH_LINK"/> <condition-expr field-name="caContentAssocTypeId" value="RESPONSE"/> </condition-list> </condition-list> <order-by field-name="createdDate"/> </entity-condition> </actions>
You may even call an OFBiz Service from within an OFBiz widget. For example, the following XML snippet taken from a Screen widget definition (available out-of-the-box) calls a Service to assemble resources for a web page:
<actions> <service service-name="getVisualThemeResources"> <field-map field-name="visualThemeId"/> <field-map field-name="themeResources" from-field="layoutSettings"/> </service> </actions>
3.145.50.222