1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.tagsnavigation.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  /**
31   * <a href="ConfigurationActionImpl.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Eduardo Lundgren
34   */
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          boolean showCompanyCategories = ParamUtil.getBoolean(
49              actionRequest, "showCompanyCategories");
50  
51          String portletResource = ParamUtil.getString(
52              actionRequest, "portletResource");
53  
54          PortletPreferences preferences =
55              PortletPreferencesFactoryUtil.getPortletSetup(
56                  actionRequest, portletResource);
57  
58          preferences.setValue(
59              "show-company-categories", String.valueOf(showCompanyCategories));
60  
61          preferences.store();
62  
63          SessionMessages.add(
64              actionRequest, portletConfig.getPortletName() + ".doConfigure");
65      }
66  
67      public String render(
68              PortletConfig portletConfig, RenderRequest renderRequest,
69              RenderResponse renderResponse)
70          throws Exception {
71  
72          return "/html/portlet/tags_entries_navigation/configuration.jsp";
73      }
74  
75  }