AquaLogic .NET Portlet Toolkit AquaLogic Interaction (ALI) Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Manipulating ALI Preferences Using the .NET Portlet Toolkit

To access and update ALI preferences using the .NET Portlet Toolkit, use preference attributes or a preference collection.

Preference attributes provide type specific read-write binding of an ALI preference to a page member variable (field). One of the following access modifiers is required on all local fields that are bound to a preference using a preference attribute: [protected | internal | protected internal | public]. The modifier “private” is not supported. Since this is the default modifier for a field if none is specified, the modifier must not be omitted. Preference attributes can be bound to fields with types of String, int, float, bool, or DateTime. Values for fields marked with preference attributes are set after the OnLoad() page event; any changes are persisted during the OnUnload() page event.
ALIPortletPageexposes a preference attribute for each type of preference: PortletPreferenceAttribute, CommunityPreferenceAttribute, CommunityPortletPreferenceAttribute, AdminPreferenceAttribute, UserPreferenceAttribute, and SessionPreferenceAttribute. All preference attributes have two optional properties:
  • Key: A string that provides the key name of the property to which the member variable is bound. If you do not include this property, the name of the preference defaults to the name of the variable. Key values must be unique within a page.
  • DefaultValue: A string that provides the value to use when the preference is unavailable or has not yet been set.
Note: Private variables (including those with no permissions modifier) cannot be seen by reflection and are not supported. You must include a permissions modifier of public, protected or internal.
[PortletPreference]
protected int myIntPref;

[PortletPreference(Key = "lastAccessed", DefaultValue = "2008-01-01")]
protected DateTime lastAccessedDateTime;

Preference collections allow you to enumerate all of the preference values in the request using the PreferenceCollection.Keys property. ALIPortletPage provides a preference collection for each type of preference: PortletPreferences, CommunityPreferences, CommunityPortletPreferences, AdminPreferences, UserPreferences, and SessionPreferences.

String myPrefValue = this.PortletPreferences["MyPrefName"];
this.PortletPreferences["MyPrefName"] = myPrefValue;

The examples above use PortletAttribute and PortletPreferences, but could be replaced with Admin*, User*, Community*, CommunityPortlet* or Session* to read preferences of the corresponding type. (Most preferences can also be set from a portlet page, but Admin preferences must be set from an preference page.)

For a full description of the API, see the complete class documentation for the ALI section of the Portlet API, installed into the Microsoft Visual Studio 2005 Integrated Help System.

For details on the types of preferences available in ALI, see Portlet Settings and Preferences in the ALI 6.0 development documentation.

  Back to Top      Previous Next