Studio Developer Manual / Version 2107
Table Of Contents
You probably want to persist the state of your tabs across sessions and website reloads. As
described above, the xtype of all open tabs is stored automatically which allows you to create the
correct tab instances when reloading. However, this does not help to persist the content of
the tabs. You have to take care of persisting tab state yourself. For example, when the user
sets the URL of the browse tab in the example the URL will be restored after reload. Such
internal state of the tab can be stored implementing the interface StateHolder
as
BrowseTabBase
of the example does:
... public class BrowseTabBase extends Panel implements StateHolder { ... public function getStateValueExpression():ValueExpression { if (!stateValueExpression) { stateValueExpression = ValueExpressionFactory.createFromValue({url: url}); } return stateValueExpression; } ... } }
Example 7.71. Base class for browser tab
To store the states of the open tabs CoreMedia Studio uses
getStateValueExpression
of each tab which implements the interface.
See section Section 7.7, “Storing Preferences” for details
of how the state is persisted and for the limits on the allowed
state structures.
You must make
sure that proper state is delivered via the state value expression. In
BrowseTabBase
this is achieved in the following way:
... internal function reloadHandler():void { var url:String = getTrigger().getValue(); getBrowseFrame().setUrl(url); if (url) { setTitle(url); } //store the url as state in the user preference getStateValueExpression().setValue({url: url}); } } }
The reloadHandler
is invoked when the user clicks on the trigger button. The
value of the trigger becomes the URL of the iFrame of the tab. Finally, the state value is set
to {url: url}
: As described above, url
is a configuration parameter
of BrowseTab
and consequently, {url:url}
is a configuration object
with the parameter url
with the trigger value. This configuration object will be
copied to the configuration object of BrowseTab
when restoring it. So
BrowseTab
's configuration parameter url
is then set to the stored
value.