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