i’m trying to get the portletPreferences enter in my ConfigActionImpl which is like this :
public void processAction(PortletConfig arg0, ActionRequest arg1,
ActionResponse arg2) throws Exception {
String portletResource = ParamUtil.getString(arg1, "portletResource");
final String newlink= ParamUtil.getString(arg1, "newlink");
final PortletPreferences portletPreferences =
PortletPreferencesFactoryUtil.getPortletSetup(arg1, portletResource);
portletPreferences.setValue("newlink", newlink);
portletPreferences.store();
SessionMessages.add(arg1, arg0.getPortletName() + ".doConfigure");
}
I want to have default preferences display in the first load, and change it if i want.
I was thinking it is like this:
protected String showView(ModelMap model, PortletRequest request) {
preferences.getValue("newlink", monUrl);
}
this is the only part of my portlet which don’t work, and when i wrote the url directly, the url is well load.
And then, i use monUrl in the code.
I have a null pointer exception
I don’t know very much portletPreferences and found nothing can help me.
I just want to load preferences in my variable and use it after.
I found on my own how to fix it.
In fact i replaced in showView this “PortletRequest request” by this “PortletPreferences preferences”
and this “preferences.getValue(“newlink”, monUrl);” by “monUrl preferences.getValue(“newlink”, monUrl);”
And it works fine.