AppliBuilder
Visual Mashup Builder

AppliBuilder User Documentation

Providing User Settings for Your Application

AppliBuilder Framework supports managing user settings for the application. 

About User Settings

Many application allows user to set different values for a given key depending on which the application behavior changes.

For example, A Wiki application can allow each user to set the value for a key "notifyOnPageChange" to either true/false.

Depending on this value the notification will be sent to the user on page change.

AppliBuilder Framework currently supports managing this basic user setting model.

Default Settings for Application

You can define the default settings for the user of application in the file "properties.txt" under web folder of the application.

The format is similar to Java's property file format, while parsing the comment field will be considered as the description field.

Example:

# Send Notification if Page Changes
notifyOnPageChange = false

This will be parsed as the following setting

description = Send Notification if Page Changes
key = notifyOnPageChange
value = false

NOTE:

Save Setting for a key

Application should make sure that user will login before setting any value for a key. Use the API to save the setting as shown below.

var ajaxdb = new Applibase.db.AjaxDb();
ajaxdb.saveSetting(key, value, description, callbackFunction, async);
Where:
key -- Setting key
value -- Setting value
description -- Description for the key (if not null will overwrite the previous value)
callbackFunction -- Function to be called back after the setting is saved.
async -- true if operation should be synchronous, false for asynchronous case (default) [OPTIONAL]

This setting will be saved using the logged in username for the application.

Example:

var ajaxdb = new Applibase.db.AjaxDb();
ajaxdb.saveSetting("notifyOnPageChange", "true", "Notify User On Page Change", callbackFunction);
function callbackFunction(settingid, error) {
if(error != null) { alert("Error happend while saving the setting: " +error.message); }
else { alert("Setting saved its id is: " + settingid); }
}

Getting the Settings

Settings value can be obtained by username for the given application as shown below.

var ajaxdb = new Applibase.db.AjaxDb();
ajaxdb.getSettings(username, callbackFunction, async);
Where:
username -- Name of the user whose settings are to be obtained.
callbackFunction -- Function to be called back after the setting is saved.
async -- true if operation should be synchronous, false for asynchronous case (default) [OPTIONAL]

Example:

var ajaxdb = new Applibase.db.AjaxDb();
ajaxdb.getSettings("username", callbackFunction);
function callbackFunction(settings, error) {
if(error != null) { alert("Error happend while saving the setting: " +error.message); }
else { ajaxdb.renderSettings(settings, document.body); } // Helper function to render the settings information as table
}

You can also get the settings value from the LoginInfo as shown below.

var ajaxdb = new Applibase.db.AjaxDb();
var loginInfo = ajaxdb.checkLogin();

var settings = null;
try {
settings = loginInfo.settings();
} catch(error) {
alert("Error getting Settings: " +error.message);
}

Here settings is list of Applibase.db.UserSettingsInfo instance.

UserSettingInfo Class

UserSettingsInfo has the following API's

Get Setting Info By Key

You can get setting information by key in the following ways:

var ajaxdb = new Applibase.db.AjaxDb();
ajaxdb.getSettingByKey(username, settingkey, callbackFunction);

function callbackFunction(settingInfo, error) {
// Use settingInfo instance if error is null.
}

var ajaxdb = new Applibase.db.AjaxDb();
var loginInfo = ajaxdb.checkLogin();
var settingInfo = loginInfo.settingInfo(settingkey);



© 2006 Applibase, Inc.