org.liferay.jukebox.template.SongsPortletDisplayTemplateHandler.java Source code

Java tutorial

Introduction

Here is the source code for org.liferay.jukebox.template.SongsPortletDisplayTemplateHandler.java

Source

/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package org.liferay.jukebox.template;

import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.portletdisplaytemplate.BasePortletDisplayTemplateHandler;
import com.liferay.portal.kernel.template.TemplateVariableGroup;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portlet.portletdisplaytemplate.util.PortletDisplayTemplateConstants;

import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.liferay.jukebox.model.Song;
import org.liferay.jukebox.util.PortletKeys;

/**
 * @author Eduardo Garcia
 */
public class SongsPortletDisplayTemplateHandler extends BasePortletDisplayTemplateHandler {

    @Override
    public String getClassName() {
        return Song.class.getName();
    }

    @Override
    public String getName(Locale locale) {
        String portletTitle = PortalUtil.getPortletTitle(PortletKeys.SONGS, locale);

        return portletTitle.concat(StringPool.SPACE).concat(LanguageUtil.get(locale, "template"));
    }

    @Override
    public String getResourceName() {
        return PortletKeys.SONGS;
    }

    @Override
    public Map<String, TemplateVariableGroup> getTemplateVariableGroups(long classPK, String language,
            Locale locale) throws Exception {

        Map<String, TemplateVariableGroup> templateVariableGroups = super.getTemplateVariableGroups(classPK,
                language, locale);

        TemplateVariableGroup templateVariableGroup = templateVariableGroups.get("fields");

        templateVariableGroup.empty();

        templateVariableGroup.addCollectionVariable("songs", List.class, PortletDisplayTemplateConstants.ENTRIES,
                "song", Song.class, "curSong", "name");

        return templateVariableGroups;
    }

}