Commerce Composer widget architecture

Widgets are the interchangeable building blocks that a Management Center user can use to compose layouts for store pages. Widgets are independent user interface modules that retrieve and display a specific type of data on a store page. Figure 1. Layout containing multiple widgets. The following image illustrates a page layout that is built using a selection of widgets.

A widget has two components:

For general information about widgets, see


Site-level and store-level widgets

Before a widget can be used with the Commerce Composer tool, the widgets must be registered within the database for the Commerce Composer framework, Widgets can be registered for use at the site-level or store-level.


Custom widget development

Widgets are composed of multiple components, including storefront and Management Center components. Your company can create custom widgets to add to the widget library by defining the storefront, Management Center, and data information for the widget. We must also use the Data Load utility to load the registration and subscription data for a widget. For more information about creating widgets, see Creating Commerce Composer widgets.

Your company can use widgets that are created by third-party vendors if the widgets are created to work with the Commerce Composer tool. To use a third-party widget, the widget must still be registered within the Commerce Composer framework and subscribed to by the store.


Storefront components

The storefront components of a widget consist of the top-level JSP file for the widget, the user interface providers, and a data provider. By defining the UI providers and data provider in separate files, there is a clear separation of data and presentation components for the widget. As a result, customizing or upgrading a widget is easier, and code is reused. Figure 2. Widget storefront components. The following diagram illustrates how the main storefront components for a widget interact.


Management Center components

When a Management Center user adds a widget to a layout template slot, the properties view for a widget display for configuration by the Management Center user. Figure 3. Widget properties view. Sample properties view for a widget

The properties view displays the following information:

When a user saves the property settings, the values for the property along with the slot and layout template information is saved in the PLWIDGETNVP database table. If a widget has properties that are defined which must be saved in a different table than the PLWIDGETNVP table, the widget manager class is used to determine how to save the property value. The widget manager class is also used for retrieving the saved property value information from the database.

For more information about the properties available and used for the widgets provided by default, see Commerce Composer widget properties. For a widget to be supported for use in Management Center, an object definition, properties view definition, and any translatable text for the widget must be defined:


Widget Manager

When the user adds a widget into a slot, the user can then set the values for the configurable properties of the widget. When the user saves the property settings, the values are saved with information to associate the widget and layout with property value in the PLWIDGETNVP database table. Some configurable properties must be saved in different database tables. A widget manager class is used to determine how to save the property settings. The widget manager is also used to validate the settings and retrieve the settings when the widget is being rendered on the storefront. When a user selects to edit a widget within a layout, the ReadWidgetManager retrieves the widget identifier information. Then, the widget manager retrieves the widget property settings specific for the layout. The widget manager class is specified in the definition XML for a widget.

If we are creating custom widgets that use marketing related data, we can use a provided widget manager class to save the data. If the provided widget manager classes do not save the data that your widget requires, we can create a custom widget manager class (mediator) to handle the data. For more information about the widget manager class, see Defining a Commerce Composer widget manager class.


Widget groups

Widget groups are sets of widgets that we can categorize our custom widgets into for two purposes:


Responsive widgets

All of the widgets that are in the Commerce Composer widget library by default are responsive. Responsive widgets display according to device screen sizes. For example, the faceted navigation widget automatically expands as display sizes grow larger.

A responsive widget does not have a fixed width. When you place a responsive widget in a slot in a template, the widget width automatically adjusts to accommodate the content within the slot. Most responsive widgets do not have a fixed height. We can use responsive widgets in responsive layout templates, as well as desktop and mobile layout templates that contain fixed widths.

If we created a custom widget, we can make your widget responsive. See Creating a responsive widget.

For more information about responsive widgets, see Responsive widgets.


Caching

The widgets for the store and site can be cached to improve storefront performance. Every widget that is provided by default has a cachespec.xml file entry that sets the caching parameters for the widget. However, not all widgets are cached by default. Whether a widget is cached, and how the widget is cached depends on the widget functionality. For more information about caching Commerce Composer widgets, see Commerce Composer widget caching and invalidation.


Related tasks
Creating Commerce Composer widget groups


Related reference
Example: How widgets can display products and prices according to a B2B contract