当前位置: 首页>>代码示例>>Java>>正文


Java ResourceResponse.setProperty方法代码示例

本文整理汇总了Java中javax.portlet.ResourceResponse.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceResponse.setProperty方法的具体用法?Java ResourceResponse.setProperty怎么用?Java ResourceResponse.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.portlet.ResourceResponse的用法示例。


在下文中一共展示了ResourceResponse.setProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serveResource

import javax.portlet.ResourceResponse; //导入方法依赖的package包/类
/**
 * Serve the resource as specified in the given request to the given response,
 * using the PortletContext's request dispatcher.
 * <p>This is roughly equivalent to Portlet 2.0 GenericPortlet.
 * @param request the current resource request
 * @param response the current resource response
 * @param context the current Portlet's PortletContext
 * @throws PortletException propagated from Portlet API's forward method
 * @throws IOException propagated from Portlet API's forward method
 */
public static void serveResource(ResourceRequest request, ResourceResponse response, PortletContext context)
		throws PortletException, IOException {

	String id = request.getResourceID();
	if (id != null) {
		if (!PortletUtils.isProtectedResource(id)) {
			PortletRequestDispatcher rd = context.getRequestDispatcher(id);
			if (rd != null) {
				rd.forward(request, response);
				return;
			}
		}
		response.setProperty(ResourceResponse.HTTP_STATUS_CODE, "404");
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:PortletUtils.java

示例2: serveResource

import javax.portlet.ResourceResponse; //导入方法依赖的package包/类
/**
 * Fornece o arquivo CSV
 */
@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException,
		PortletException {

	if (hasPermission(resourceRequest)) {

		resourceResponse.setContentType("text/csv; charset=ISO-8859-1");
		resourceResponse.setCharacterEncoding("ISO-8859-1");
		resourceResponse.setProperty("content-disposition", "attachment;filename=contadores.csv");

		OutputStream os = resourceResponse.getPortletOutputStream();
		Writer writer = new OutputStreamWriter(os, Charset.forName(resourceResponse.getCharacterEncoding()));

		long companyId = PortalUtil.getCompanyId(resourceRequest);
		try {
			writer.write(ContadorAcessoLocalServiceUtil.getCSV(companyId));
		} catch (SystemException e) {
			throw new PortletException(e);
		}
		writer.flush();
	} else {
		super.serveResource(resourceRequest, resourceResponse);
	}

}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:29,代码来源:ContadoresPortlet.java

示例3: serveResource

import javax.portlet.ResourceResponse; //导入方法依赖的package包/类
/**
 * Routes between portlet resources
 *
 * @param request  The request
 * @param response The response
 *
 * @throws PortletException If something goes wrong
 * @throws IOException      If something goes wrong
 */
@Override
public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    PortletResource resource = PortletResource.getResource(request);

    switch(resource) {
        case LOAD_MORE:
            this.doLoadMore(request, response);
        break;
        default:
            response.setProperty(ResourceResponse.HTTP_STATUS_CODE, STATUS_CODE_NOT_FOUND);
        break;
    }
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:23,代码来源:FlashlightSearchPortlet.java

示例4: doLoadMore

import javax.portlet.ResourceResponse; //导入方法依赖的package包/类
/**
 * Performs the "load more" AJAX request
 *
 * @param request The resource request
 * @param response The resource response
 *
 * @throws PortletException If something goes wrong
 * @throws IOException If something goes wrong
 */
public void doLoadMore(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    response.setContentType(ContentTypes.APPLICATION_JSON);
    response.setCharacterEncoding(StandardCharsets.UTF_8.name());
    response.setProperty(HTTP_HEADER_CACHE_CONTROL, CACHE_CONTROL_NO_CACHE);
    response.setProperty(ResourceResponse.EXPIRATION_CACHE, ZERO);

    String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK);
    int offset = ParamUtil.getInteger(request, PortletRequestParameter.PAGE_OFFSET.getName(), 0);
    if(offset < 0) {
        offset = 0;
    }

    FlashlightSearchConfiguration config = this.searchService.readConfiguration(request.getPreferences());
    Map<String, FlashlightSearchConfigurationTab> tabs = config.getTabs();

    if(tabs.containsKey(tabId)) {
        try {
            SearchResultsContainer container = this.searchService.search(request, response, tabId, offset, true);
            JSONPayloadFactory jsonPayloadFactory = new JSONPayloadFactory(this.jsonFactory);
            if(container.hasSearchResults(tabId)) {
                FlashlightSearchConfigurationTab tab = tabs.get(tabId);
                SearchPage page = container.getSearchPage(tabId);

                ResourceURL loadMoreUrl = response.createResourceURL();
                loadMoreUrl.setResourceID(PortletResource.LOAD_MORE.getResourceId());
                loadMoreUrl.setParameter(PortletRequestParameter.TAB_ID.getName(), tabId);
                loadMoreUrl.setParameter(PortletRequestParameter.KEYWORDS.getName(), ParamUtil.get(request, PortletRequestParameter.KEYWORDS.getName(), StringPool.BLANK));
                loadMoreUrl.setParameter(PortletRequestParameter.PAGE_OFFSET.getName(), Integer.toString(offset + 1));
                loadMoreUrl.setParameter(PortletRequestParameter.RANDOM_CACHE.getName(), randomCacheParamValue());

                JSONObject payload = jsonPayloadFactory.createJSONPayload(tab, page, offset, loadMoreUrl.toString());
                response.getWriter().print(payload.toJSONString());
            } else {
                // No search results with the given tab
                LOG.debug("A search tab was found, but no pages were returned");
                response.setProperty(ResourceResponse.HTTP_STATUS_CODE, STATUS_CODE_NOT_FOUND);
            }
        } catch (SearchException e) {
            // Cannot perform search, return a 500 error
            LOG.error("Cannot perform search", e);
            response.setProperty(ResourceResponse.HTTP_STATUS_CODE, STATUS_CODE_INTERNAL_ERROR);
        }
    } else {
        // No tab with given ID. Return 404
        response.setProperty(ResourceResponse.HTTP_STATUS_CODE, STATUS_CODE_NOT_FOUND);
    }
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:57,代码来源:FlashlightSearchPortlet.java

示例5: resourceFirst

import javax.portlet.ResourceResponse; //导入方法依赖的package包/类
@ResourceMapping("first")
public String resourceFirst(ResourceResponse response) {
	response.setProperty("RESPONSE", "resourceFirst");
	return "resourceFirst";
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:Portlet20AnnotationControllerTests.java

示例6: processResource

import javax.portlet.ResourceResponse; //导入方法依赖的package包/类
@ResourceMapping("second")
public String processResource(ResourceResponse response) {
	response.setProperty("RESPONSE", "resourceSecond");
	return "resourceSecond";
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:Portlet20AnnotationControllerTests.java


注:本文中的javax.portlet.ResourceResponse.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。