001
014
015 package com.liferay.portlet.navigation.action;
016
017 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
018 import com.liferay.portal.kernel.servlet.SessionMessages;
019 import com.liferay.portal.kernel.util.Constants;
020 import com.liferay.portal.kernel.util.ParamUtil;
021 import com.liferay.portlet.PortletPreferencesFactoryUtil;
022
023 import javax.portlet.ActionRequest;
024 import javax.portlet.ActionResponse;
025 import javax.portlet.PortletConfig;
026 import javax.portlet.PortletPreferences;
027 import javax.portlet.RenderRequest;
028 import javax.portlet.RenderResponse;
029
030
033 public class ConfigurationActionImpl extends BaseConfigurationAction {
034
035 public void processAction(
036 PortletConfig portletConfig, ActionRequest actionRequest,
037 ActionResponse actionResponse)
038 throws Exception {
039
040 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
041
042 if (!cmd.equals(Constants.UPDATE)) {
043 return;
044 }
045
046 String displayStyle = ParamUtil.getString(
047 actionRequest, "displayStyle");
048 String bulletStyle = ParamUtil.getString(actionRequest, "bulletStyle");
049 String headerType = ParamUtil.getString(actionRequest, "headerType");
050 String rootLayoutType = ParamUtil.getString(
051 actionRequest, "rootLayoutType");
052 int rootLayoutLevel = ParamUtil.getInteger(
053 actionRequest, "rootLayoutLevel");
054 String includedLayouts = ParamUtil.getString(
055 actionRequest, "includedLayouts");
056 boolean nestedChildren = ParamUtil.getBoolean(
057 actionRequest, "nestedChildren");
058
059 String portletResource = ParamUtil.getString(
060 actionRequest, "portletResource");
061
062 PortletPreferences preferences =
063 PortletPreferencesFactoryUtil.getPortletSetup(
064 actionRequest, portletResource);
065
066 preferences.setValue("display-style", displayStyle);
067 preferences.setValue("bullet-style", bulletStyle);
068
069 if (displayStyle.equals("[custom]")) {
070 preferences.setValue("header-type", headerType);
071 preferences.setValue("root-layout-type", rootLayoutType);
072 preferences.setValue(
073 "root-layout-level", String.valueOf(rootLayoutLevel));
074 preferences.setValue("included-layouts", includedLayouts);
075 preferences.setValue(
076 "nested-children", String.valueOf(nestedChildren));
077 }
078
079 preferences.store();
080
081 SessionMessages.add(
082 actionRequest, portletConfig.getPortletName() + ".doConfigure");
083 }
084
085 public String render(
086 PortletConfig portletConfig, RenderRequest renderRequest,
087 RenderResponse renderResponse)
088 throws Exception {
089
090 return "/html/portlet/navigation/configuration.jsp";
091 }
092
093 }