Search code examples
liferayportalliferay-theme

Liferay - Theme - Questions about get configurable settings via themeDisplay.getTheme().getSetting() in spring mvc controller


This is my question:

I use the following way to add configurable settings to my theme. <setting key="theme-mode" configurable="true" value="default"></setting>

and then use theme.getSetting("theme-mode") in my freemarker theme to get the value ,it is working well.

Now I want to get the configurable value in my spring mvc controller:

ThemeDisplay themeDisplay=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY); String themeMode = themeDisplay.getTheme().getSetting("theme-mode");

but themeMode got default ,I already change it in the edit page ,and theme.getSetting("theme-mode") in theme is work well.

do you know why ,please tell me.

Thank you for your help!


Solution

  • Try this:

    ThemeDisplay td = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    System.out.println(td.getThemeSetting("theme-mode"));
    

    I've tried this on my portlet and it's working