Using The Widget Context Bean

During the process of rendering a widget, the Widget Framework maintains a widget context bean in the request scope called widget. The widget bean is a java.util.Map by default. It contains information about the current context widget and provides access to the intermediate data processed by the Controller and ModelProcessor. The widget bean is removed at the end of the widget's life cycle.

Note that if a nested widget is loaded from another widget context then widget represents the nested widget if retrieved from nested widget rendering code.

The widget bean has the following properties:

  • ${widget.model} - A bean ( java.util.Map by default) created from the widget's content field values. The string representation of a widget content field value can be retrieved from this bean using the field name as property name.

  • ${widget.viewName} - The name of the widget's selected view.

  • ${widget.properties} - A bean ( java.util.Map by default) created from the widget's properties

  • ${widget.widgetContent} - The widget content item as a PresentationArticle object.

  • ${widget.widgetName} - The name of the widget.

  • ${widget.contentResult} - The Data Source result of a Data Source client widget (for example, a Teaser widget)

  • ${widget.invokingWidget} - The widget bean of the invoking widget if the current context widget is invoked by another widget. A Teaser View widget, for example, is invoked by a View Picker widget. Teaser Views do not have a Data Source of their own, they are supplied with data by their invoking View Picker. So if you want to access the Data Source results from a Teaser View widget, you have to use ${widget.invokingWidget.contentResult}.

In Widget Framework version 2.2.0 and earlier a bean was created based on the widget name. For a widget called Hello World, for example, the Widget Framework controller would create a bean called helloWorld. This bean was used to hold widget field values and processed intermediate data. Use of this bean is now deprecated and it will be removed in a future version of the Widget Framework. You are therefore advised not to use it. Use ${widget.model} instead.

Please note that we do not recommend adding objects directly to the request scope in order to pass values into JSP pages in a widget. Please use the widget context bean instead.