Studio Developer Manual / Version 2107
Table Of Contents
In many cases, it is not necessary to create your 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:
<?xml version="1.0" encoding="UTF-8"?> <!--- A widget state for adding simple search widgets to the dashboard default view. --> <editor:WidgetState xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:exml="http://www.jangaroo.net/exml/0.8" xmlns="exml:ext.config" xmlns:editor="exml:com.coremedia.cms.editor.sdk.config" widgetTypeId="{SimpleSearchWidget.xtype}"> <fx:Metadata>[PublicApi]</fx:Metadata> <fx:Script><![CDATA[ private var config:SimpleSearchWidgetState; public native function SimpleSearchWidgetState(config:SimpleSearchWidgetState = null); ]]></fx:Script> <fx:Declarations> <!--- The search text that is used for the collection view. Default "". --> <fx:String id="searchText"/> <!--- The content type that is used in the content type filter. Default "Document_". --> <fx:String id="contentType"/> <!--- Whether to restrict the search to the preferred site. Default true. --> <fx:Boolean id="preferredSite"/> </fx:Declarations> </editor:WidgetState>
Example 7.79. 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
.