This section of the guide describes specific properties of the iWidget framework in IBM® Lotus® Connections. These properties are simple extensions to the iWidget specification and they are common to the Lotus Connections features that support iWidgets, that is Communities, Home page, and Profiles.
Lotus Connections 2.5 supports three types of widget.
Table 1. Widget types
|
|
|
|
|
Mandated widgets are required. This type of widget cannot be removed, hidden, or moved.
Mandated widgets can exist outside of a community or a profile. For example, the Public Communities page or the Search Results page in Profiles can contain this type of widget in addition to a community page or a user profile in Profiles.
|
|
|
This type of widget is displayed by default, but it can be removed, hidden, or moved by the owner.
|
|
|
Optional widgets are not displayed by default. This type of widget can be added, removed, hidden, and moved.
|
In Lotus Connections 2.5, Communities supports all the different widget types, and the owner of a community can customize that community by adding any type of widget. The Home page feature supports optional widgets and widgets that are open by default. A Home page user can customize their home page by adding either of these widget types. Profiles only support mandated widgets.
Using the Dojo JavaScript Toolkit
Lotus Connections supports version 1.2.3 of the Dojo JavaScript toolkit. You do not have to perform any extra steps to load Dojo; you can expect Dojo to be already on the page and Dojo methods can be used directly in the widget code. If specific Dojo classes are required for your development, and they are not already loaded in to the page, those Dojo classes will be downloaded automatically.
Obtaining information about the logged in user with “UserProfile”
The userProfile Object is a predefined itemSet that allows you to get information about the authenticated user. Because profiles and communities allow anonymous access, expect the return values to be null when the user is not logged in.
Lotus Connections provides an itemSet to get details about the authenticated user, iContext.getUserProfile(). This returns an immutable itemSet with the following items:
- displayName: the display name of the logged in user
- email: the e-mail address of the logged in user, if available
- userid: the Lotus Connections user ID of the logged in user
The following example retrieves the user ID of an authenticated user:
this.iContext.getUserProfile().getItemValue('userid');
Persisting widget preferences using managed itemSets
You can persist preferences on a widget basis across sessions by using the attributes managed itemSet. The attributes managed itemSet behaves in the same way as a standard itemSet and provides an additional save() method. This feature is supportes by the Communities and Home page features in Lotus Connections 2.5.
Note: The save operation invokes an HTTP request to the server, so you should use this function as little as possible. When the widget is removed, the attributes are also removed.
For example:
this.iContext.getiWidgetAttributes().setItemValue("name", "myValue");
this.iContext.getiWidgetAttributes().save();
Working with an Ajax Proxy using the IO Module
The JavaScript security model does not allow cross-domain requests. This policy might cause some limitations for widgets that need to interact with a server located on a domain that is different from the Lotus Connections domain. To overcome this limitation, Lotus Connections provides an Ajax Proxy that forwards the requests to the remote domain server. Information regarding the configuration of the Ajax Proxy can be found in the Security > Configuring the Ajax proxy section of the Lotus Connections Information Center.
A JavaScript API is provided as part of the iWidget specification for using the Ajax proxy. The method rewriteURI on the IO module takes a URL and returns a rewritten URL that can be used to trigger an Ajax request through the local Ajax proxy.
For example:
var myUrl = "http://mycompany.com/test.xml";
var proxiedURL = this.iContext.io.rewriteURI(myUrl);
Widget wiring
This feature is not supported in Lotus Connections 2.5, but widget developers can take advantage of the Dojo publish/subscribe API to perform widget-to-widget interactions in a flexible, loosely-coupled manner.
Parent topic
Lotus Connections iWidget Development Guide
Related topics
iWidget Overview
iWidget support in the Home page
iWidget support in Profiles and Communities
Best practices for iWidget development
Authors: Vincent Burckhardt and Ronny A Pena