001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.breadcrumb.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    /**
031     * @author Brian Wing Shun Chan
032     */
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    
049                    String portletResource = ParamUtil.getString(
050                            actionRequest, "portletResource");
051    
052                    PortletPreferences preferences =
053                            PortletPreferencesFactoryUtil.getPortletSetup(
054                                    actionRequest, portletResource);
055    
056                    preferences.setValue("display-style", displayStyle);
057    
058                    preferences.store();
059    
060                    SessionMessages.add(
061                            actionRequest, portletConfig.getPortletName() + ".doConfigure");
062            }
063    
064            public String render(
065                            PortletConfig portletConfig, RenderRequest renderRequest,
066                            RenderResponse renderResponse)
067                    throws Exception {
068    
069                    return "/html/portlet/breadcrumb/configuration.jsp";
070            }
071    
072    }