Example usage for com.vaadin.server VaadinPortletService getCurrentResponse

List of usage examples for com.vaadin.server VaadinPortletService getCurrentResponse

Introduction

In this page you can find the example usage for com.vaadin.server VaadinPortletService getCurrentResponse.

Prototype

public static VaadinPortletResponse getCurrentResponse() 

Source Link

Document

Gets the currently processed Vaadin portlet response.

Usage

From source file:de.unioninvestment.eai.portal.portlet.crud.CrudUI.java

License:Apache License

private void tryToSetPortletTitle(String title) {
    String realTitle = title != null ? title : Context.getMessage("portlet.crud.window.name");
    String escapedTitle = StringEscapeUtils.escapeJavaScript(realTitle);

    PortletResponse portletResponse = VaadinPortletService.getCurrentResponse().getPortletResponse();
    if (portletResponse instanceof RenderResponse) {
        ((RenderResponse) portletResponse).setTitle(realTitle);
    } else {/*from w ww.  ja v  a 2s .  co  m*/
        // document.querySelectorAll("#portlet_crudportlet_WAR_eaiadministration_INSTANCE_qeH6QK9czlb6 .portlet-title-text")[0].childNodes[0].nodeValue
        // = 'Releaseplaner - Applikationen'
        String ie8plusUpdate = "document.querySelectorAll('#portlet_" + getPortletId()
                + " .portlet-title-text')[0]" + ".childNodes[0].nodeValue = '" + escapedTitle + "'";
        String defaultUpdate = "document.getElementById('portlet_" + getPortletId()
                + "').getElementsByClassName('portlet-title-text')[0]" + ".childNodes[0].nodeValue = '"
                + escapedTitle + "'";
        String all = "if (document.querySelectorAll) { " + ie8plusUpdate + " } else { " + defaultUpdate + " };";
        JavaScript.getCurrent().execute(all);
    }
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.ui.BusinessExceptionMessage.java

License:Apache License

private void buildUi(String message) {
    try {//from w  w w .j  av a2  s.  c  o m
        PortletURL url = ((MimeResponse) VaadinPortletService.getCurrentResponse().getPortletResponse())
                .createRenderURL();
        url.setPortletMode(PortletMode.EDIT);
        ExternalResource editUrl = new ExternalResource(url.toString());
        setCompositionRoot(new Link(message, editUrl));

    } catch (PortletModeException e1) {
        // not allowed
        setCompositionRoot(new Label(message));
    }
}

From source file:de.unioninvestment.eai.portal.support.vaadin.PortletUtils.java

License:Apache License

/**
 * Gibt dem Browser die Information, zu einer alternativen Ansicht des
 * Portlets zu wechseln./*w  w w  . j av a  2  s.  c om*/
 * 
 * @param targetMode
 *            der Ziel-Modus
 * @return <code>true</code>, falls ein Wechsel erfolgen kann
 */
public static boolean switchPortletMode(PortletMode targetMode) {
    try {
        PortletResponse response = VaadinPortletService.getCurrentResponse().getPortletResponse();
        if (response instanceof MimeResponse) {
            PortletURL url = ((MimeResponse) response).createRenderURL();
            url.setPortletMode(targetMode);
            Page.getCurrent().setLocation(url.toString());
            return true;

        } else if (response instanceof StateAwareResponse) {
            ((StateAwareResponse) response).setPortletMode(targetMode);
            return true;

        } else {
            LOGGER.error("Portlet mode can only be changed from a portlet request");
            return false;
        }

    } catch (IllegalStateException e) {
        // not in portlet: then don't switch back
        return false;

    } catch (PortletModeException e) {
        // not allowed: then don't switch back
        return false;
    }
}

From source file:de.unioninvestment.eai.portal.support.vaadin.support.UnconfiguredMessage.java

License:Apache License

/**
 * Konstruktor.//from w ww .  java2s.  c om
 */
public UnconfiguredMessage() {
    String message = Context.getMessage("portlet.crud.info.unconfigured");
    try {
        PortletResponse portletResponse = VaadinPortletService.getCurrentResponse().getPortletResponse();
        PortletURL url = ((MimeResponse) portletResponse).createRenderURL();
        url.setPortletMode(PortletMode.EDIT);
        ExternalResource editUrl = new ExternalResource(url.toString());
        setCompositionRoot(new Link(message, editUrl));

    } catch (PortletModeException e) {
        // not allowed
        setCompositionRoot(new Label(message));
    }
}