loading table of contents...

7.13.4.3. Custom Widget State Class

In many cases, it is not necessary to create you own widget state class for your custom widget type. As shown earlier in this chapter, the predefined class WidgetState allows you to set the dashboard column, the widget type and the widget's rowspan. This is sufficient unless you want to put widgets of your type into the default dashboard and at the same time use a configuration other than the default. However, if you want to do just that, CoreMedia recommends that you create your own widget state class as an extension to WidgetState. For the simple search widget, the custom state class SimpleSearchWidgetState looks as follows:

<exml:class ...>
  ...

  <exml:cfg name="searchText" type="String">
    <exml:description>
      ...	
    </exml:description>
  </exml:cfg>

  <exml:cfg name="contentType" type="String">
    <exml:description>
      ...
    </exml:description>
  </exml:cfg>

  <exml:cfg name="preferredSite" type="Boolean">
    <exml:description>
      ...
    </exml:description>
  </exml:cfg>

  <editor:widgetState widgetTypeId="{simpleSearchDashlet.xtype}"/>
</exml:class>

Example 7.57. widget State Class for Simple Search widget


This class allows you to launch simple search widgets initially with the configuration properties searchText and contentType being set. They are set via the dashboard configuration prior to the dashboard's launch instead of being set by the user via the SimpleSearchWidgetEditor component at runtime (although this is of course possible afterwards).

The widgetTypeId for the SimpleSearchWidgetState is set to the xtype of SimpleSearchWidget. This is because widget types that extend ComponentBasedWidgetType by default take the xtype of their widget component as their id.