<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Unable to read portlet preferences with Spring 2.5</title>
  <link rel="self" href="https://liferay.dev/hu/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=3616715" />
  <subtitle>Unable to read portlet preferences with Spring 2.5</subtitle>
  <id>https://liferay.dev/hu/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=3616715</id>
  <updated>2026-06-06T10:57:53Z</updated>
  <dc:date>2026-06-06T10:57:53Z</dc:date>
  <entry>
    <title>RE: Unable to read portlet preferences with Spring 2.5</title>
    <link rel="alternate" href="https://liferay.dev/hu/c/message_boards/find_message?p_l_id=119785294&amp;messageId=3622783" />
    <author>
      <name>Marcel van den Brink</name>
    </author>
    <id>https://liferay.dev/hu/c/message_boards/find_message?p_l_id=119785294&amp;messageId=3622783</id>
    <updated>2009-07-22T07:53:02Z</updated>
    <published>2009-07-22T07:53:02Z</published>
    <summary type="html">Got it!&lt;br /&gt;&lt;br /&gt;Preferences are read when the portlet is put on the page. Since the preferences were added after the portlet was put on a page, they were not available.&lt;br /&gt;&lt;br /&gt;Removing the portlet and putting a fresh instance on a page resolved my problem.&lt;br /&gt;&lt;br /&gt;Thanks for reading.  :-)</summary>
    <dc:creator>Marcel van den Brink</dc:creator>
    <dc:date>2009-07-22T07:53:02Z</dc:date>
  </entry>
  <entry>
    <title>Unable to read portlet preferences with Spring 2.5</title>
    <link rel="alternate" href="https://liferay.dev/hu/c/message_boards/find_message?p_l_id=119785294&amp;messageId=3616714" />
    <author>
      <name>Marcel van den Brink</name>
    </author>
    <id>https://liferay.dev/hu/c/message_boards/find_message?p_l_id=119785294&amp;messageId=3616714</id>
    <updated>2009-07-21T14:21:56Z</updated>
    <published>2009-07-21T14:21:56Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi,&lt;br&gt;&lt;br&gt;I'm trying to read the portlet settings using Spring Portlet MVC 2.5, but so far no luck.  &lt;img alt="emoticon" src="@theme_images_path@/emoticons/sad.gif"&gt;&lt;br&gt;&lt;br&gt;My portlet.xml with preferences is:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
&amp;lt;!--?xml version="1.0" encoding="UTF-8"?--&amp;gt;

&amp;lt;portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
                        http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"&amp;gt;

    &amp;lt;portlet&amp;gt;
        &amp;lt;description&amp;gt;Portlet displaying the user account summary&amp;lt;/description&amp;gt;
        &amp;lt;portlet-name&amp;gt;user-account-portlet&amp;lt;/portlet-name&amp;gt;
        &amp;lt;display-name&amp;gt;User account summary&amp;lt;/display-name&amp;gt;

        &amp;lt;!--  &amp;lt;portlet-class&amp;gt;nl.detelefoongids.oase.portlet.BasePortlet&amp;lt;/portlet-class&amp;gt;  --&amp;gt;
        
        &amp;lt;portlet-class&amp;gt;org.springframework.web.portlet.DispatcherPortlet&amp;lt;/portlet-class&amp;gt;
        &amp;lt;init-param&amp;gt;
            &amp;lt;name&amp;gt;contextConfigLocation&amp;lt;/name&amp;gt;
            &amp;lt;value&amp;gt;/WEB-INF/context/baseportlet.xml&amp;lt;/value&amp;gt;
        &amp;lt;/init-param&amp;gt;
        

        &amp;lt;supports&amp;gt;
            &amp;lt;mime-type&amp;gt;text/html&amp;lt;/mime-type&amp;gt;
            &amp;lt;portlet-mode&amp;gt;view&amp;lt;/portlet-mode&amp;gt;
            &amp;lt;portlet-mode&amp;gt;edit&amp;lt;/portlet-mode&amp;gt;
        &amp;lt;/supports&amp;gt;

        &amp;lt;supported-locale&amp;gt;en&amp;lt;/supported-locale&amp;gt;

        &amp;lt;portlet-info&amp;gt;
            &amp;lt;title&amp;gt;User account summary&amp;lt;/title&amp;gt;
            &amp;lt;short-title&amp;gt;User account summary&amp;lt;/short-title&amp;gt;
            &amp;lt;keywords&amp;gt;base default portlet user account summary&amp;lt;/keywords&amp;gt;
        &amp;lt;/portlet-info&amp;gt;

        &amp;lt;portlet-preferences&amp;gt;
            &amp;lt;preference&amp;gt;
                &amp;lt;name&amp;gt;test&amp;lt;/name&amp;gt;
                &amp;lt;value&amp;gt;123456test&amp;lt;/value&amp;gt;
            &amp;lt;/preference&amp;gt;
        &amp;lt;/portlet-preferences&amp;gt;
    &amp;lt;/portlet&amp;gt;
&amp;lt;/portlet-app&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;The code to read them is:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
package customer.packagename;

import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(value = "EDIT")
public class DefaultEditController {

    @RequestMapping
    public String handleActionRequest(ModelMap model, PortletRequest request) {

        PortletPreferences preferences = (PortletPreferences)request.getPreferences();
        System.out.println("Action: Preferences = " + preferences);
        System.out.println("Action: Preferences map leeg? = "+ preferences.getMap().isEmpty());
        System.out.println("Action: Preferences - test = " + preferences.getValue("test", "default value"));
        System.out.println("Action: Preferences - presentation = " + preferences.getValues("presentation", new String[]{"1"}).length);
        
        // model.addAttribute("test", preferences.getValue("test", "not set!"));
        return "edit";
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Somehow the map is always empty and so the values passed as 'default value' are always returned (and not the '123456test' as I was hoping for).&lt;br&gt;&lt;br&gt;What am I doing wrong?! This problem has cost me all day... and I'm starting to get depressed.   &lt;img alt="emoticon" src="@theme_images_path@/emoticons/happy.gif"&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Marcel van den Brink</dc:creator>
    <dc:date>2009-07-21T14:21:56Z</dc:date>
  </entry>
</feed>
