Work with the PortletWindow object
The PortletWindow object represents portlets on portal pages and sends events to portlets; for example, when users minimize or close the window. Portlets can send also send requests to the window to determine the current state of the window.
Attributes
Note: Client side attributes represent a special client side concept that can help you scope JavaScriptâ„¢ entities, such as variables.
Client side aggregation of previous portal versions:For all the following attributes:
void clearAttributes() Object getAttribute(Sting name) Object setAttribute(String name, String value) void removeAttribute(String name)
Enabler API:There is no analog concept to these attributes for portlets that use the Enabler API. When you write portlets, scope JavaScript entities by prefixing, for example with the window ID of the portlet.
iWidget API:When you use the iWidget API, put JavaScript entities into the iScope.
Portlet preferences
Client side aggregation of previous portal versions:Object getPortletPreferences(Function callbackfn)
Enabler API:var result = WidgetModel.getHierachicalPreferences(preferenceProvider)In contrast, valid PreferenceProviders are:
- widgetDefinition . This maps to config .
- widgetInstance . This maps to edit shared settings .
- widgetWindow . This maps to personalize .
iWidget API:When you use the iWidget API, put JavaScript entities into the iScope.
Client side aggregation in previous portal versions:Mixed setPortletPreferences(PortletPreferences preferences, Function callbackfn)
Mixed setPortletPreferences(PortletPreferences preferences, Function callbackfn)
Enabler API:var navigationModel = com.ibm.mashups.enabler.navigation.Factory.getNavigationModel(); var selectedNode = navigationModel.find(<pageID>).start(); var layoutModel = navigationModel.getLayoutModel(selectedNode); var layoutControl = layoutModel.find(<windowID>).start(); var widgetInstance = widgetModel.getWidgetWindow(layoutControl).start(); // set preferences var modifiablePreferences = widgetModel.getHierarchicalPreferences(widgetInstance).start(); modifiablePreferences.setValues(key, values); // commit this.widgetModel.commit().start();
iWidget API:When you use the iWidget API, use iWidgetAttributes :
var result = iContext.getiWidgetAttributes(); result.setItemValue(itemName, itemValue);
Portlet state
Client side aggregation in previous portal versions:Object getPortletState(Function callbackfn)
Enabler API:There is no analog PortletState object in the Enabler API. Follow the approach given here :
var navigationStateModel = navigationStateModel; var widgetAccessor = com.ibm.mashups.enabler.model.state.AccessorFactory.getWidgetAccessor(navigationStateModel, <windowID>); // fetch the widget mode var widgetMode = widgetAccessor.getWidgetMode(); // fetch the widget window state var widgetState = widgetAccessor.getWindowState(); // fetch all available widget states var widgetStateNames = widgetAccessor.getWidgetStateNames(); var result = new Array(); for (var n = 0; n < widgetStateNames.length; n++) { var widgetStates = this.getParameterValues(widgetStateNames [n]); result [n] = {name: widgetStateNames [n], values: widgetStates}; }
iWidget API:Use the call onNavStateChanged()call , as iWidgets maintain parameters by themselves.
Client side aggregation in previous portal versions:Object setPortletState(PortletState state, Function callbackfn)
Enabler API:var navigationStateModel = navigationStateModel; var widgetAccessor = com.ibm.mashups.enabler.model.state.AccessorFactory.getWidgetAccessor(navigationStateModel, <windowID>); // set the widget mode widgetAccessor.setWidgetMode(widgetMode); // set the widget window state widgetAccessor.setWindowState(windowState); // set widget states widgetAccessor.setWidgetStates(name, values); // commit navigationStateModel.commit().start();
iWidget API:Use the call onNavStateChanged()call , as iWidgets maintain parameters by themselves.
User profile
Client side aggregation in previous portal versions:Object getUserProfile(Function callbackfn)
Enabler API:var userModel = com.ibm.mashups.enabler.user.Factory.getUserModel(); // fetching user attributes var user = userModel.findCurrentUser().start(); var result = user.getAttribute(name);
iWidget API:var userProfile = iContext.getUserProfile();
Client side aggregation in previous portal versions:Object setUserProfile(UserProfile, Function callbackfn)
Enabler API:var userModel = com.ibm.mashups.enabler.user.Factory.getUserModel(); // setting user attributes var user = userModel.findCurrentUser().start(); user.setAttribute(name, value); // commit userModel.commit().start();
iWidget API:var userProfile = iContext.getUserProfile(); userProfile.setAttribute(name, value);
Parent
Comparing the new and the old client-side programming model