Work with the PortletPreferences object
The PortletPreferences object stores, sets, and retrieves portlet settings.
Client side aggregation of previous portal versions:void clone()
Enabler API:Not available.
iWidget API:Not available.
Client side aggregation of previous portal versions:Object [] getMap()
Enabler API:var preferenceNames = this.getPreferenceNames(); // see below var result = new Array(); for (var n=0; n<preferenceNames.length; n++) { var preferenceValues = this.getValues(preferenceNames [n]); // see below var preferenceIsReadOnly = this.isReadOnly(preferenceNames [n]); // see below result [n] = { name: preferenceNames [n], values: preferenceValues, readOnly: preferenceIsReadOnly }; }
iWidget API:Not available.
Client side aggregation of previous portal versions:String getValue(String key, String def)
Enabler API:// fetch ModifiablePreferences 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(); var modifiablePreferences = widgetModel.getHierarchicalPreferences(widgetInstance).start(); // get value var result = modifiablePreferences.getValue(key);
iWidget API:var iWidgetAttributes = iContext.getiWidgetAttributes(); var result = iWidgetAttributes.getItemValue(String itemName);
Client side aggregation of previous portal versions:String [] getValues(String key, String [] def)
Enabler API:// fetch ModifiablePreferences 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(); var modifiablePreferences = widgetModel.getHierarchicalPreferences(widgetInstance).start(); // get values var result = modifiablePreferences.getValues(key);
iWidget API:Not available as iWidgetAttributes are single-valued.
Client side aggregation of previous portal versions:boolean isReadOnly(String key)
Enabler API:// fetch ModifiablePreferences 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(); var modifiablePreferences = widgetModel.getHierarchicalPreferences(widgetInstance).start(); // fetch isReadOnly var result = modifiablePreferences.isReadOnly(key);
iWidget API:var iWidgetAttributes = iContext.getiWidgetAttributes(); var result = iWidgetAttributes.isReadOnly(String itemName);
Client side aggregation of previous portal versions:void reset(String key)
Enabler API:// fetch ModifiablePreferences 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(); var modifiablePreferences = widgetModel.getHierarchicalPreferences(widgetInstance).start(); // reset var result = modifiablePreferences.remove(key); // commit widgetModel.commit().start();
iWidget API:var iWidgetAttributes = iContext.getiWidgetAttributes(); var result = iWidgetAttributes.removeItem(String itemName);
Client side aggregation of previous portal versions:void setValue(String key, String value)
Enabler API:// fetch ModifiablePreferences 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(); var modifiablePreferences = widgetModel.getHierarchicalPreferences(widgetInstance).start(); // set value modifiablePreferences.setValue(key, value); // commit widgetModel.commit().start();
iWidget API:var iWidgetAttributes = iContext.getiWidgetAttributes(); var result = iWidgetAttributes.setItemValue(String itemName. String value, boolean readOnly);
Client side aggregation of previous portal versions:void setValues(String key, String [] values)
Enabler API:// fetch ModifiablePreferences 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(); var modifiablePreferences = widgetModel.getHierarchicalPreferences(widgetInstance).start(); // set values modifiablePreferences.setValues(key, value); // commit widgetModel.commit().start();
iWidget API:Not available as iWidgetAttributes are single-valued.
Parent
Comparing the new and the old client-side programming model