User preferences (UserPrefs) can be used by app developers to store configuration values for a given user of a particular app. UserPrefs are typically set by the users and persist across a given instance of a gadget. Typical UserPrefs can include things like color or size of gadget, or other personalization options like location information. For example a gadget which searches for materials via WorldCat Search API might allow users to set libraries to limit them search to.
UserPrefs are made up of the following attributes:
Example
<UserPref name="zip_code" display_name="Zip Code" datatype="string" default_value="" required="false" />
<UserPref name="typeOfLibrary" display_name="What kind of libraries are you looking for?" datatype="enum" default_value="" required="false">
<EnumValue value="public" display_value="Public Library" />
<EnumValue value="academic" display_value="Academic Library" />
<EnumValue value="special" display_value="Special Library" />
</UserPref>
UserPrefs are accessible via app code in two different ways:
Extra Prefs
Example
var prefs = new gadgets.Prefs();
var name = prefs.getString("name");
${Prefs.[UserPref_name]}
Extra Prefs
Example
${Prefs.name}
The OCLC Developer Network supports the use of OCLC Web Services—a set of tools and APIs that expose data and services for WorldCat and our member libraries and partner institutions or companies. learn more »
© 2010 OCLC Domestic and international trademarks and/or service marks of OCLC Online Computer Library Center, Inc. and its affiliates
Follow the OCLC Developer Network: