Using the iWidget persistent data store
When building iWidgets for IBM Connections, you oftentimes have the need to store data for an end user. For example, you may interested in storing a user name, some preferences, etc. Did you know that you can use the iWidget persistent data store to accomplish this? This data store persists across browser sessions, the clearing of a browser cache, and even through server restarts! It’s a great way to store some data.
When you use the data store, an HTTP request will be made to the Connections server any time you invoke the save operation. For site performance reasons, you should probably limit the number of save operations you make. For example, if you need to store lots of data, you should consider consolidating it into a single JSON object, and then write the serialized string to the data store. This will allow you to save / retrieve all of your data with a single API operation.
var attrs = this.iContext.getiWidgetAttributes(); attrs.setItemValue("MyKey", "MyValue"); attrs.save();
var attrs = this.iContext.getiWidgetAttributes(); var value = attrs.getItemValue("MyKey");
Enjoy your new iWidget capabilities! You can now persist data across sessions and bring a more personalized experience to your end users!