Search in sources :

Example 11 with PortletURL

use of javax.portlet.PortletURL in project liferay-blade-samples by liferay.

the class BladeActionConfigurationIcon method getURL.

public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {
    HttpServletRequest servletRequest = _portal.getHttpServletRequest(portletRequest);
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    FileEntry fileEntry = _retrieveFile(servletRequest);
    PortletURL portletURL = PortletURLFactoryUtil.create(servletRequest, "blade_document_action_portlet_BladeDocumentActionPortlet", themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
    String fileName = fileEntry.getFileName();
    String mimeType = fileEntry.getMimeType();
    String version = fileEntry.getVersion();
    String createdDate = String.valueOf(fileEntry.getCreateDate());
    String createdUserName = fileEntry.getUserName();
    String statusLabel = null;
    try {
        FileVersion fileVersion = fileEntry.getLatestFileVersion();
        int status = fileVersion.getStatus();
        statusLabel = WorkflowConstants.getStatusLabel(status);
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
    }
    portletURL.setParameter("fileName", fileName);
    portletURL.setParameter("mimeType", mimeType);
    portletURL.setParameter("version", version);
    portletURL.setParameter("statusLabel", statusLabel);
    portletURL.setParameter("createdDate", createdDate);
    portletURL.setParameter("createdUserName", createdUserName);
    try {
        portletURL.setWindowState(LiferayWindowState.POP_UP);
    } catch (WindowStateException wse) {
        _log.log(LogService.LOG_ERROR, wse.getMessage(), wse);
    }
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("javascript:Liferay.Util.openWindow(");
    stringBuilder.append("{dialog: {cache: false,width:800,modal: true},");
    stringBuilder.append("title: 'basic information',id: ");
    stringBuilder.append("'testPopupIdUnique',uri: '");
    stringBuilder.append(portletURL.toString() + "'});");
    return stringBuilder.toString();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WindowStateException(javax.portlet.WindowStateException) FileVersion(com.liferay.portal.kernel.repository.model.FileVersion) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) PortalException(com.liferay.portal.kernel.exception.PortalException) ThemeDisplay(com.liferay.portal.kernel.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Example 12 with PortletURL

use of javax.portlet.PortletURL in project acs-community-packaging by Alfresco.

the class AlfrescoFacesPortlet method getRenderURL.

/**
 * Creates a render URL from the given request and parameters
 *
 * @param request
 *           the request
 * @param parameters
 *           the parameters
 * @return the render url
 */
public static String getRenderURL(ServletRequest request, Map<String, String[]> parameters) {
    RenderResponse renderResp = (RenderResponse) request.getAttribute("javax.portlet.response");
    if (renderResp == null) {
        throw new IllegalStateException("RenderResponse object is null");
    }
    PortletURL url = renderResp.createRenderURL();
    url.setParameters(parameters);
    return url.toString();
}
Also used : RenderResponse(javax.portlet.RenderResponse) PortletURL(javax.portlet.PortletURL)

Example 13 with PortletURL

use of javax.portlet.PortletURL in project liferay-ide by liferay.

the class AlbumAssetRenderer method getURLViewInContext.

@Override
public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) {
    try {
        long plid = PortalUtil.getPlidFromPortletId(_album.getGroupId(), PortletKeys.ALBUMS);
        if (plid == LayoutConstants.DEFAULT_PLID) {
            return StringPool.BLANK;
        }
        PortletURL portletURL = PortletURLFactoryUtil.create(liferayPortletRequest, PortletKeys.ALBUMS, plid, PortletRequest.RENDER_PHASE);
        portletURL.setParameter("jspPage", "/html/albums/view_album.jsp");
        portletURL.setParameter("albumId", String.valueOf(_album.getAlbumId()));
        return portletURL.toString();
    } catch (Exception e) {
    }
    return StringPool.BLANK;
}
Also used : PortletURL(javax.portlet.PortletURL) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException)

Example 14 with PortletURL

use of javax.portlet.PortletURL in project liferay-ide by liferay.

the class AlbumAssetRenderer method getURLEdit.

@Override
public PortletURL getURLEdit(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws Exception {
    PortletURL portletURL = liferayPortletResponse.createLiferayPortletURL(getControlPanelPlid(liferayPortletRequest), AlbumsPortlet.PORTLET_ID, PortletRequest.RENDER_PHASE);
    portletURL.setParameter("jspPage", "/html/albums/edit_album.jsp");
    portletURL.setParameter("albumId", String.valueOf(_album.getAlbumId()));
    return portletURL;
}
Also used : PortletURL(javax.portlet.PortletURL)

Example 15 with PortletURL

use of javax.portlet.PortletURL in project liferay-ide by liferay.

the class ArtistAssetRenderer method getURLViewInContext.

@Override
public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) {
    try {
        long plid = PortalUtil.getPlidFromPortletId(_artist.getGroupId(), PortletKeys.ARTISTS);
        if (plid == LayoutConstants.DEFAULT_PLID) {
            return StringPool.BLANK;
        }
        PortletURL portletURL = PortletURLFactoryUtil.create(liferayPortletRequest, PortletKeys.ARTISTS, plid, PortletRequest.RENDER_PHASE);
        portletURL.setParameter("jspPage", "/html/artists/view_artist.jsp");
        portletURL.setParameter("artistId", String.valueOf(_artist.getArtistId()));
        return portletURL.toString();
    } catch (Exception e) {
    }
    return StringPool.BLANK;
}
Also used : PortletURL(javax.portlet.PortletURL) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException)

Aggregations

PortletURL (javax.portlet.PortletURL)26 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)6 KBArticle (com.liferay.knowledgebase.model.KBArticle)5 PortalException (com.liferay.portal.kernel.exception.PortalException)5 KBFolder (com.liferay.knowledgebase.model.KBFolder)4 SystemException (com.liferay.portal.kernel.exception.SystemException)3 WindowStateException (javax.portlet.WindowStateException)3 PortletPreferences (javax.portlet.PortletPreferences)2 Album (org.liferay.jukebox.model.Album)2 Song (org.liferay.jukebox.model.Song)2 JSONObject (com.liferay.portal.kernel.json.JSONObject)1 LiferayPortletURL (com.liferay.portal.kernel.portlet.LiferayPortletURL)1 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)1 FileVersion (com.liferay.portal.kernel.repository.model.FileVersion)1 ThemeDisplay (com.liferay.portal.kernel.theme.ThemeDisplay)1 Layout (com.liferay.portal.model.Layout)1 LayoutTypePortlet (com.liferay.portal.model.LayoutTypePortlet)1 Portlet (com.liferay.portal.model.Portlet)1 PortalPreferences (com.liferay.portlet.PortalPreferences)1 BlogsEntry (com.liferay.portlet.blogs.model.BlogsEntry)1