Widgets

From InfiniteERP Wiki
Revision as of 10:28, 16 December 2021 by Wikiadmin (talk | contribs) (Created page with "{{WorkInProgress}} == Introduction == In Openbravo 3 Widgets are UI elements which can be either placed in a Users' Workspace tab or be part of a generated window. They can...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Warning.png   This document is still a work in progress. It may contain inaccuracies or errors.

Introduction

In Openbravo 3 Widgets are UI elements which can be either placed in a Users' Workspace tab or be part of a generated window. They can be used to display a wide range of different information ranging from static content, over dynamic database data in list form, custom html content, or complete external URL's.

Bulbgraph.png   Placing Widget in a generated window is only available from version 3.0MP2 or later

The following images show two example widgets which are provided by the Widget Collection module provided with the Openbravo 3 distribution.

The first one shows a list of invoices ready to be collected with live data from the Openbravo database. The second example shows an interactive motion chart.

Widget showing Invoices to collect with live data from the Openbravo database Interactive widget showing a motion chart

The rest of this article explains how to define such a widget with its parameters, the different available 'types' of widget and the differences in widget definitions if those are to be placed in a generated window.

Widget class & Widget Instance

Defining a new widget class

Extending a existing widget class

Defining widget parameters

Available Widget Superclasses

Defining a widget for use in a generated window

If a widget is planned to be embed into a generated Window/Tab as explained in this HowTo then a few differences/restrictions must be observed.

  • User visible differences: Widgets embedded in a Tab do not have a titlebar/menu. This means that widgets embedded in a Tab do not offer the following customization/options:
    • Edit of parameters
    • Removing/moving/Maximizing the widget
    • Use of custom menu items (i.e. Export as CSV)
  • Differences in definition
    • No Widget Instance, all parameters must be defined on the Widget directly
    • Parameters can use values of the currently displayed record

Use of current record in parameters

When a widget is displayed inside a generated Window/Tab then it is possible to define a parameters which will contain the field values of the currently displayed record.

To do this the parameter needs to be declared as described above with the following settings:

  • Fixed: not marked
  • Default Value: ${formValues.name}

The name in the expression for the Default Value refers to the Name field of the current record. The name to be used for a field in this expression is the property name of the column, so the same which is also used in an HQL query.

If the property is an Entity (i.e. Product) ${formValues.product} will contain the id (UUID) of the Entity

At runtime this parameter will automatically contain the fields' value as the parameter value.

Note: If there is no current value (i.e. the form displayed in New mode) then the expression string is send as is to the widget. The widget implementation is expected to handle such a case.