ArcGIS Flexviewer All the widget classes inherit from the Com.esri.viewer.BaseWidget base class, and Basewidget inherits the Com.esri.viewer.IBaseWidget interface. All widgets are managed by the Widgetmanager class. Therefore, to achieve the value from the application to the widget, it needs to be done through Widgetmanager. For example, when a user logs in with a user name, the user name needs to be validated in the widget, and the user name (string) can be passed to all widgets that inherit the base class of the widget described in the following steps.
1, modify the Ibasewidget interface file, add the following function definition:
function set userName (value:string):void; function get userName (): String;
2. Implement the above method in the base class Basewidget:
Private var _username:string; [Bindable]publicfunctionget userName (): string{ return _username;} Public function set userName (value:string):void{ = value;}
3, according to the above method, define the relevant variables and property accessors in Widgetmanager, as follows:
Private var user_name:string; [Bindable]publicfunctionset userName (value:string):void { = value; } [Bindable]publicfunctionget userName (): String { return user_name;}
4. Assume that application (typically the home page) has a string variable named Usernamestr, which is defined in the Mxml declaration of Widgetmanager as follows:
< Viewer:widgetmanager > < ID= "Widgetmanager" userName= "{usernamestr}"/> </viewer:widgetmanager>
5. In the Createwidget function of the Widgetmanager class, in widget.map = map; Add the following code after the statement:
this. userName;
6, Test. User name is admin, add in widget:
Alert.show (this. userName);
Execute the relevant code to see a message box from the widget:
Done.
Application to widgets in ArcGIS Flexviewer