org.oep.cmon.admin.portlet.util.SetParamUtil.java Source code

Java tutorial

Introduction

Here is the source code for org.oep.cmon.admin.portlet.util.SetParamUtil.java

Source

/*
 * Copyright (c) 2014 by Open eGovPlatform (http://http://openegovplatform.org/).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *  http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.oep.cmon.admin.portlet.util;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;

import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.util.JavaConstants;

/** 
 * This is class SetParamUtil
 * 
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  1-April-2013  Nam Dinh    Create new
 */
public class SetParamUtil {

    public static int DA_XOA_DEACTIVATE = 1;
    public static int DA_XOA_ACTIVATE = 0;

    /**
     * This is function setParameter
     * Version: 1.0
     *  
     * History: 
     *   DATE        AUTHOR      DESCRIPTION 
     *  ------------------------------------------------- 
     *  3-March-2013  Nam Dinh    Create new
     * @param actionRequest
     * @param actionResponse
     * @param value
     */
    public static void setParameter(ActionRequest actionRequest, ActionResponse actionResponse, String value) {
        if (value != null) {
            actionResponse.setRenderParameter("searchKeyWord", value);
        }

        // Hidden default error message
        PortletConfig portletConfig = (PortletConfig) actionRequest
                .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
        SessionMessages.add(actionRequest,
                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
    }

    /**
     * This is function print error message
     * Version: 1.0
     *  
     * History: 
     *   DATE        AUTHOR      DESCRIPTION 
     *  ------------------------------------------------- 
     *  3-March-2013  Nam Dinh    Create new
     * @param err
     */
    public static void printError(String err) {
        System.out.println(err);
    }

    /**
     * This is function print exception
     * Version: 1.0
     *  
     * History: 
     *   DATE        AUTHOR      DESCRIPTION 
     *  ------------------------------------------------- 
     *  3-March-2013  Nam Dinh    Create new
     * @param err
     */
    public static void printException(Exception err) {
        err.printStackTrace();
    }
}