1
14
15 package com.liferay.portlet.navigation.action;
16
17 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
18 import com.liferay.portal.kernel.servlet.SessionMessages;
19 import com.liferay.portal.kernel.util.Constants;
20 import com.liferay.portal.kernel.util.ParamUtil;
21 import com.liferay.portlet.PortletPreferencesFactoryUtil;
22
23 import javax.portlet.ActionRequest;
24 import javax.portlet.ActionResponse;
25 import javax.portlet.PortletConfig;
26 import javax.portlet.PortletPreferences;
27 import javax.portlet.RenderRequest;
28 import javax.portlet.RenderResponse;
29
30
35 public class ConfigurationActionImpl extends BaseConfigurationAction {
36
37 public void processAction(
38 PortletConfig portletConfig, ActionRequest actionRequest,
39 ActionResponse actionResponse)
40 throws Exception {
41
42 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
43
44 if (!cmd.equals(Constants.UPDATE)) {
45 return;
46 }
47
48 String displayStyle = ParamUtil.getString(
49 actionRequest, "displayStyle");
50 String bulletStyle = ParamUtil.getString(actionRequest, "bulletStyle");
51 String headerType = ParamUtil.getString(actionRequest, "headerType");
52 String rootLayoutType = ParamUtil.getString(
53 actionRequest, "rootLayoutType");
54 int rootLayoutLevel = ParamUtil.getInteger(
55 actionRequest, "rootLayoutLevel");
56 String includedLayouts = ParamUtil.getString(
57 actionRequest, "includedLayouts");
58 boolean nestedChildren = ParamUtil.getBoolean(
59 actionRequest, "nestedChildren");
60
61 String portletResource = ParamUtil.getString(
62 actionRequest, "portletResource");
63
64 PortletPreferences prefs =
65 PortletPreferencesFactoryUtil.getPortletSetup(
66 actionRequest, portletResource);
67
68 prefs.setValue("display-style", displayStyle);
69 prefs.setValue("bullet-style", bulletStyle);
70
71 if (displayStyle.equals("[custom]")) {
72 prefs.setValue("header-type", headerType);
73 prefs.setValue("root-layout-type", rootLayoutType);
74 prefs.setValue(
75 "root-layout-level", String.valueOf(rootLayoutLevel));
76 prefs.setValue("included-layouts", includedLayouts);
77 prefs.setValue("nested-children", String.valueOf(nestedChildren));
78 }
79
80 prefs.store();
81
82 SessionMessages.add(
83 actionRequest, portletConfig.getPortletName() + ".doConfigure");
84 }
85
86 public String render(
87 PortletConfig portletConfig, RenderRequest renderRequest,
88 RenderResponse renderResponse)
89 throws Exception {
90
91 return "/html/portlet/navigation/configuration.jsp";
92 }
93
94 }