Skip to main content

Custom Widget Type

Developers can define custom widget types if the default set of widgets provided from OOTB D2. This helps in developing custom views and business operation to perform

Custom shortcut type in D2

D2-Smartview landing page configuration elements like <tile> requires a type attribute to be set. By default all "Widget type" found in D2-Config are accepted as valid values. However, while defining new shortcuts for the landing page tile one might need to use a value that is not a "Widget type" at all or in other words the value is not pre-defined. Additionally, while defining new application scope perspective one might need to declare a default widget name for the corresponding perspective to use when a direct URL based navigation is taking place in the UI.

To facilitate this, an SDK developer can create a properties file {Plugin}/resources/strings/config/U4Landing.properties. There are two properties that can be defined in the file -

  • default_widget_tags: This allows declaring new valid XML tag names to go under the <default-widgets> section in the D2SV landing page file. Multiple comma separated values could be specified.
  • shortcut_types: This allows declaring valid values for `type` attribute of <tile>. Multiple comma separated values could be specified.

Example

default_widget_tags=abcd,defg
shortcut_types=custom1,custom2

If this is the content of the U4Landing.properties file, then the following hypothetical landing page structure is accepted as valid configuration

<root>
<space>
<flow-layout-container>
<content>
<tile-container size="full">
<tile name="one" type="custom1">
<theme color="shade1" type="stone1"/>
</tile>
<tile name="two" type="custom2">
<theme color="shade1" type="indigo1"/>
</tile>
</tile-container>
</content>
</flow-layout-container>
</space>
<default-widgets>
<abcd>SOME_NAME</abcd>
<defg>ANOTHER</defg>
</default-widgets>
</root>

The developer needs to register the custom widget type if needed to create widgets which can driven through the D2-Config context matrix evaluation. To do this, developer needs to create a properties file {Plugin}/resources/strings/config/WidgetSubtypelist.properties. This will include all the widget type created in the format {Widget Type Name}=true

Example

CustomWidgetType=true

If developer wants the widget to inherit the properties of some other OOTB D2 widget types, then developer needs to prefix the parent widget type name in the format {Parent Widget Type Name}.{Widget Type Name}=true

Example

DocListWidget.CustomWidgetType=true

If the developer want to have custom parameters as part of the custom widget type, developer needs to add those in the properties file {Plugin}/resources/strings/config/WidgetSubtype.properties. This will include the parameters for all the widget type created for plugin in the format {Widget type Name}.{{Parameter name}={Default value}.

Example

CustomerCustomType.sample1 = Text1
CustomerCustomType.sample2 = Text2

In order to provide custom labels for the custom parameters which are created needs to be add in the properties file {Plugin}/resources/strings/actions/config/modules/widget/WidgetDialog/WidgetDialog_en.properties. Entries will be in the format label_{parameter name}={display label}.

Example

label_sample1 = Sample text field 1
label_sample2 = Sample text field 2

If the developer wants to enable default columns for a custom widget type, the following properties files must be added:

{Plugin}/src/main/resources/strings/config/WidgetColumnslist.properties - Defines the column type associated with the custom widget type. Entries follow the format: WidgetType = {columnType} (columnType with value default corresponds to DocListWidget behavior.)

CustomType = custom_colType

{Plugin}/src/main/resources/com/emc/d2/api/preferences/D2cPreferences.properties - Defines the default column configurations. Each entry uses: _col_{columnType} = columnName|size, columnName|size, ... Where size represents the column width.

_col_custom_colType = attribute1|100,attribute2|100,attribute3|100
  • For the pre-deployed plugin, if you'd like to adjust the default columns for a custom widget type using the plugin, it is mandatory to create a new entry with the key _default_plugin_{columnType} to preserve the original column configuration. Then, update the _col_{columnType} entry with your new column configuration. Please clear the preference after re-deploying the plugin to see the effect of changed plugin's default columns.
_col_custom_colType = attribute2|100,attribute5|170,attribute7|170

_default_plugin_custom_colType = attribute1|100,attribute2|100,attribute3|100

{Plugin}/src/main/resources/com/emc/d2/api/preferences/D2cPreferencesColumnType.properties - Maps each column (identified with the colType prefix) to the attribute type it represents.

custom_colType.attribute1 = 2
  • where:
    • BOOLEAN type is represented with 0
    • INTEGER type is represented with 1
    • STRING type is represented with 2
    • ID type is represented with 3
    • TIME type is represented with 4
    • DOUBLE type is represented with 5

{Plugin}/src/main/resources/strings/bundles/DfAttributeBundle_en.properties - Maps the display label for each column. Entries follow the format: type.columnName = Display Label

dm_sysobject.attribute1 = Custom Column