Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...



The communitySave object is used for giving a widget specific saved data for a given community, for example giving an intelligence community KML specific to a region of interest for a map widget or using a certain color scheme specific to business operations for a statistics widget.  The communitySave objects can only be set external to a widget in http://infinite.ikanow.com/manager/fileUploader.jsp  To make a communitySave in the fileUploader just upload a json file with a community selected and use type widgetSave, any json available to a user when a widgetLoads will be passed into the WidgetSaveObject.communitySave when onLoadWidgetOptions is called from then on.

Info
titleTo create your own communitySave

1. Create a JSON file with the data you want to pass in (see KML example below for the built in map's kml layer adder)
2. Upload the JSON file to a new JSON share in the fileUploader.jsp with the following fields set:

    1. Title: Must match the widget you want the communitySave to be accessible in, for example if you want a kml layer in the Map widget you must name your share "Map"
    2. Type: Must be "widgetsave"
    3. Community: Must be a non-personal community (e.g. select a community you own)

Any JSON saved int his manner will be available to users in that community in the onLoadWidgetOptions as seen below:

Code Block
titleLoading Community Save Data
public function onLoadWidgetOptions( widgetOptions:WidgetSaveObject ):void
{               
    if ( widgetOptions != null )
    {
        //this holds a users last map 
        if ( widgetOptions.userSave != null )
        {
              //...code from above here
        }
		if ( widgetOptions.communitySave != null )
		{
			//Any shares you have access to with type widgetSave will be provided here
			//Here we will be given a map of community ids to shares e.g. { "commid12345": {"key1":"value1"}, "commid67890":{"anotherkey",["blue","green","red"]}}
			for ( var commid:String in widgetOptions.communitySave )
			{
				//this is the object saved in the share for community <commid>
				//Now you can do what you want with it (we printed it out)
				var community_save_object = widgetOptions.communitySave[commid];
				for ( var key:String in community_save_object )
				{					
					trace("CommId: " + commid + " key: " + key + " value: " + community_save_object[key]);
					
				}
			}
		}
 	}
}

...