qdbtools.main.CustomVaadinPortlet.java Source code

Java tutorial

Introduction

Here is the source code for qdbtools.main.CustomVaadinPortlet.java

Source

/*******************************************************************************
 * QBiC User DB Tools enables users to add people and affiliations to our mysql user database.
 * Copyright (C) 2016  Andreas Friedrich
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *******************************************************************************/

package qdbtools.main;

import java.io.IOException;

import javax.portlet.PortletException;

import com.vaadin.server.DeploymentConfiguration;
import com.vaadin.server.ServiceException;
import com.vaadin.server.VaadinPortlet;
import com.vaadin.server.VaadinPortletService;
import com.vaadin.server.VaadinRequest;

/**
 * 
 * copied from:
 * https://github.com/jamesfalkner/vaadin-liferay-beacon-demo/blob/master/src/main/java/
 * com/liferay/mavenizedbeacons/CustomVaadinPortlet.java This custom Vaadin portlet allows for
 * serving Vaadin resources like theme or widgetset from its web context (instead of from ROOT).
 * Usually it doesn't need any changes.
 * 
 */
public class CustomVaadinPortlet extends VaadinPortlet {

    private class CustomVaadinPortletService extends VaadinPortletService {
        /**
         *
         */

        public CustomVaadinPortletService(final VaadinPortlet portlet, final DeploymentConfiguration config)
                throws ServiceException {
            super(portlet, config);
        }

        /**
         * This method is used to determine the uri for Vaadin resources like theme or widgetset. It's
         * overriden to point to this web application context, instead of ROOT context
         */
        @Override
        public String getStaticFileLocation(final VaadinRequest request) {
            //return super.getStaticFileLocation(request);
            // self contained approach:
            return request.getContextPath();
        }
    }

    @Override
    protected void doDispatch(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
            throws javax.portlet.PortletException, java.io.IOException {
        super.doDispatch(request, response);
    }

    @Override
    public void serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
            throws PortletException, IOException {
        super.serveResource(request, response);
    }

    @Override
    protected VaadinPortletService createPortletService(final DeploymentConfiguration deploymentConfiguration)
            throws ServiceException {
        final CustomVaadinPortletService customVaadinPortletService = new CustomVaadinPortletService(this,
                deploymentConfiguration);
        customVaadinPortletService.init();
        return customVaadinPortletService;
    }
}