Application to widgets in ArcGIS Flexviewer

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.