Search in sources :

Example 6 with BaseURL

use of javax.portlet.BaseURL in project liferay-faces-bridge-impl by liferay.

the class BaseURLRenderer method encodeEnd.

@Override
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
    BaseURL baseURL = createBaseURL(facesContext, uiComponent);
    Boolean secure = getSecure(uiComponent);
    if (secure != null) {
        try {
            baseURL.setSecure(secure);
        } catch (PortletSecurityException e) {
            throw new IOException(e);
        }
    }
    processParamChildren(uiComponent, baseURL);
    processPropertyChildren(uiComponent, baseURL);
    String varName = getVar(uiComponent);
    String url = baseURL.toString();
    if (isEscapeXml(uiComponent)) {
        url = XMLUtil.escapeXML(url);
    }
    // If the user didn't specify a value for the "var" attribute, then write the URL to the response.
    if (varName == null) {
        ResponseWriter responseWriter = facesContext.getResponseWriter();
        responseWriter.write(url);
    } else // Otherwise, place the url into the request scope so that it can be resolved via EL with the name
    // specified in the "var" attribute.
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        Map<String, Object> requestMap = externalContext.getRequestMap();
        requestMap.put(varName, url);
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) ExternalContext(javax.faces.context.ExternalContext) BaseURL(javax.portlet.BaseURL) IOException(java.io.IOException) PortletSecurityException(javax.portlet.PortletSecurityException)

Example 7 with BaseURL

use of javax.portlet.BaseURL in project struts by apache.

the class PortletUrlHelperJSR286 method createUrl.

protected Object createUrl(String scheme, String type, Map<String, String[]> portletParams) {
    MimeResponse response = (MimeResponse) PortletActionContext.getResponse();
    BaseURL url;
    if (URLTYPE_NAME_ACTION.equalsIgnoreCase(type)) {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating action url");
        url = response.createActionURL();
    } else if (URLTYPE_NAME_RESOURCE.equalsIgnoreCase(type)) {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating resource url");
        url = response.createResourceURL();
    } else {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating render url");
        url = response.createRenderURL();
    }
    url.setParameters(portletParams);
    if ("HTTPS".equalsIgnoreCase(scheme)) {
        try {
            url.setSecure(true);
        } catch (PortletSecurityException e) {
            LOG.error("Cannot set scheme to https", e);
        }
    }
    return url;
}
Also used : MimeResponse(javax.portlet.MimeResponse) BaseURL(javax.portlet.BaseURL) PortletSecurityException(javax.portlet.PortletSecurityException)

Aggregations

BaseURL (javax.portlet.BaseURL)7 ExternalContext (javax.faces.context.ExternalContext)4 IOException (java.io.IOException)3 StringWriter (java.io.StringWriter)2 PortletRequest (javax.portlet.PortletRequest)2 PortletSecurityException (javax.portlet.PortletSecurityException)2 PortletURL (javax.portlet.PortletURL)2 BaseURLBridgeURIAdapterImpl (com.liferay.faces.bridge.internal.BaseURLBridgeURIAdapterImpl)1 BridgeURI (com.liferay.faces.bridge.internal.BridgeURI)1 Writer (java.io.Writer)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 FacesContext (javax.faces.context.FacesContext)1 ResponseWriter (javax.faces.context.ResponseWriter)1 MimeResponse (javax.portlet.MimeResponse)1 PortletResponse (javax.portlet.PortletResponse)1 ResourceURL (javax.portlet.ResourceURL)1 Bridge (javax.portlet.faces.Bridge)1 PortletPhase (javax.portlet.faces.Bridge.PortletPhase)1 Test (org.junit.Test)1