本文整理汇总了Java中javax.portlet.ResourceURL.setResourceID方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceURL.setResourceID方法的具体用法?Java ResourceURL.setResourceID怎么用?Java ResourceURL.setResourceID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.portlet.ResourceURL
的用法示例。
在下文中一共展示了ResourceURL.setResourceID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResourceURL
import javax.portlet.ResourceURL; //导入方法依赖的package包/类
/**
* Creates a resource URL from the given faces context.
*
* @param context
* the faces context
* @return the resource URL
*/
public static String getResourceURL(FacesContext context, String path)
{
MimeResponse portletResponse = (MimeResponse) context.getExternalContext().getResponse();
ResourceURL resourceURL = portletResponse.createResourceURL();
resourceURL.setResourceID(path);
return resourceURL.toString();
}
示例2: doLoadMore
import javax.portlet.ResourceURL; //导入方法依赖的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);
}
}
示例3: doView
import javax.portlet.ResourceURL; //导入方法依赖的package包/类
public void doView(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
PortletConfig portletConfig =
(PortletConfig)renderRequest.getAttribute(
JavaConstants.JAVAX_PORTLET_CONFIG);
String updateMessage = getUpdateMessage(portletConfig);
renderRequest.setAttribute("updateMessage", updateMessage);
List<String> outputList = IndexCheckerOutput.generateCSVOutput(
portletConfig, renderRequest);
String portletId = portletConfig.getPortletName();
long userId = PortalUtil.getUserId(renderRequest);
String outputContent = OutputUtils.listStringToString(outputList);
FileEntry exportCsvFileEntry = OutputUtils.addPortletOutputFileEntry(
portletId, userId, outputContent);
if (exportCsvFileEntry != null) {
ResourceURL exportCsvResourceURL =
renderResponse.createResourceURL();
exportCsvResourceURL.setResourceID(exportCsvFileEntry.getTitle());
renderRequest.setAttribute(
"exportCsvResourceURL", exportCsvResourceURL.toString());
}
try {
List<Long> siteGroupIds = this.getSiteGroupIds();
renderRequest.setAttribute("groupIdList", siteGroupIds);
List<String> groupDescriptionList = getSiteGroupDescriptions(
siteGroupIds, renderRequest.getLocale());
renderRequest.setAttribute(
"groupDescriptionList", groupDescriptionList);
}
catch (Exception e) {
throw new PortletException(e);
}
try {
List<Model> modelList = this.getModelList();
renderRequest.setAttribute("modelList", modelList);
}
catch (SystemException se) {
throw new PortletException(se);
}
long filterModifiedDate = ParamUtil.getLong(
renderRequest, "filterModifiedDate", 0L);
renderRequest.setAttribute("filterModifiedDate", filterModifiedDate);
super.doView(renderRequest, renderResponse);
}
示例4: createResourceURL
import javax.portlet.ResourceURL; //导入方法依赖的package包/类
/**
* Create resource URL for a resourceId
*
* @param renderResponse
* @param resourceId
*
* @return url string
*/
protected String createResourceURL(RenderResponse renderResponse, String resourceId) {
ResourceURL portletURL = renderResponse.createResourceURL();
portletURL.setResourceID(resourceId);
return portletURL.toString();
}