Commits all changes that are made to the preferences via the set methods to the persistent store. All changes that are made to the preferences and not followed by a call to this function are discarded when the portlet finishes action processing.
This function produces an error if the preferences cannot be written for any reason.
portalLib.savePreferences()
portalLib.setPreferenceValue("username", user);
portalLib.setPreferenceValue("maxResultCount", "10");
portalLib.savePreferences();