O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining User Preferences

You may need to save user preference variables persistently within an application’s OpenSocial gadget. This is where the UserPref element comes into play. It allows you to configure which variables you would like to store for a user. These configuration variables, along with JavaScript features we will talk about in later sections, provide simple key/value storage without requiring you to set up a database.

UserPref contains a number of configurable attributes, listed in Table 3-7.

Table 3-7. UserPref attributes

Attribute

Description

datatype

An optional string that denotes the date type present within the user preference variable. The value may be string (default value), bool, enum, hidden (not visible or user-editable), or list (dynamic array generated from user input).

default_value

An optional string that stores a default value for a user preference in the event that the user does not specify a variable configuration.

display_name

An optional string that represents the user preference during editing. This value must be unique.

name

The name of the user preference. This value is required and must be a unique value.

required

An optional Boolean value (true/false) indicating whether the user preference variable is required or not. The default value is false (not required).

urlparam

If a Content section within an XML gadget has the type set to url, signifying a separate file from which to load data, this optional parameter is passed along to that file as well if these ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required