本文整理汇总了Java中javax.portlet.PortletContext.getRequestDispatcher方法的典型用法代码示例。如果您正苦于以下问题:Java PortletContext.getRequestDispatcher方法的具体用法?Java PortletContext.getRequestDispatcher怎么用?Java PortletContext.getRequestDispatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.portlet.PortletContext
的用法示例。
在下文中一共展示了PortletContext.getRequestDispatcher方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serveResource
import javax.portlet.PortletContext; //导入方法依赖的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");
}
}
示例2: checkParameters
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected TestResult checkParameters(PortletContext context,
PortletRequest request,
PortletResponse response)
throws IOException, PortletException {
// Dispatch to the companion servlet: call checkParameters().
StringBuffer buffer = new StringBuffer();
buffer.append(SERVLET_PATH).append("?")
.append(KEY_TARGET).append("=").append(TARGET_PARAMS)
.append("&").append(KEY_A).append("=").append(VALUE_A)
.append("&").append(KEY_B).append("=").append(VALUE_B);
if (LOG.isDebugEnabled()) {
LOG.debug("Dispatching to: " + buffer.toString());
}
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
return result;
}
示例3: checkSameNameParameter
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected TestResult checkSameNameParameter(PortletContext context,
PortletRequest request,
PortletResponse response)
throws IOException, PortletException {
// Dispatch to the companion servlet: call checkSameNameParameter().
StringBuffer buffer = new StringBuffer();
buffer.append(SERVLET_PATH).append("?")
.append(KEY_TARGET).append("=").append(TARGET_SAME_NAME_PARAM)
.append("&").append(KEY_C).append("=").append(VALUE_C1)
.append("&").append(KEY_C).append("=").append(VALUE_C2)
.append("&").append(KEY_C).append("=").append(VALUE_C3);
if (LOG.isDebugEnabled()) {
LOG.debug("Dispatching to: " + buffer.toString());
}
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
return result;
}
示例4: checkAddedSameNameParameter
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected TestResult checkAddedSameNameParameter(PortletContext context,
PortletRequest request,
PortletResponse response)
throws IOException, PortletException {
// Dispatch to the companion servlet: call checkAddedSameNameParameter().
StringBuffer buffer = new StringBuffer();
buffer.append(SERVLET_PATH).append("?")
.append(KEY_TARGET).append("=").append(TARGET_ADDED_SAME_NAME_PARAM)
.append("&").append(KEY_RENDER).append("=").append(VALUE_ADDED1)
.append("&").append(KEY_RENDER).append("=").append(VALUE_ADDED2);
if (LOG.isDebugEnabled()) {
LOG.debug("Dispatching to: " + buffer.toString());
}
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
return result;
}
示例5: checkInvalidParameters
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected TestResult checkInvalidParameters(PortletContext context,
PortletRequest request,
PortletResponse response)
throws IOException, PortletException {
// Dispatch to the companion servlet: call checkInvalidParameters().
StringBuffer buffer = new StringBuffer();
buffer.append(SERVLET_PATH).append("?")
.append(KEY_TARGET).append("=").append(TARGET_INVALID_PARAMS)
.append("&").append(KEY_A)
.append("&").append(KEY_B).append("=").append(VALUE_B)
.append("&").append(KEY_C).append("=");
if (LOG.isDebugEnabled()) {
LOG.debug("Dispatching to: " + buffer.toString());
}
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
return result;
}
示例6: sendToJSP
import javax.portlet.PortletContext; //导入方法依赖的package包/类
public static void sendToJSP(PortletContext pContext,
RenderRequest request, RenderResponse response,
String jspPage) throws PortletException {
response.setContentType(request.getResponseContentType());
if (jspPage != null && jspPage.length() != 0) {
try {
PortletRequestDispatcher dispatcher = pContext
.getRequestDispatcher(jspPage);
dispatcher.include(request, response);
} catch (IOException e) {
throw new PortletException("Sakai Dispatch unabble to use "
+ jspPage, e);
}
}
}
示例7: doCheckIncludedAttribute
import javax.portlet.PortletContext; //导入方法依赖的package包/类
private TestResult doCheckIncludedAttribute(PortletContext context,
PortletRequest request,
PortletResponse response,
String pathInfo)
throws IOException, PortletException {
// Save expected values as request attributes.
String contextPath = request.getContextPath();
String requestUri = contextPath + SERVLET_PATH + pathInfo;
request.setAttribute(EXPECTED_REQUEST_URI, requestUri);
request.setAttribute(EXPECTED_CONTEXT_PATH, contextPath);
// Dispatch to the companion servlet: call checkParameters().
StringBuffer buffer = new StringBuffer();
buffer.append(SERVLET_PATH).append(pathInfo).append("?")
.append(QUERY_STRING);
if (LOG.isDebugEnabled()) {
LOG.debug("Dispatching to: " + buffer.toString());
}
PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
buffer.toString());
dispatcher.include((RenderRequest) request, (RenderResponse) response);
// Retrieve test result returned by the companion servlet.
TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
request.removeAttribute(RESULT_KEY);
request.removeAttribute(EXPECTED_REQUEST_URI);
request.removeAttribute(EXPECTED_CONTEXT_PATH);
return result;
}
示例8: doView
import javax.portlet.PortletContext; //导入方法依赖的package包/类
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
PortletContext context = getPortletContext();
PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(getViewPage());
requestDispatcher.include(request, response);
}
示例9: doEdit
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
PortletContext context = getPortletContext();
PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(getEditPage());
requestDispatcher.include(request, response);
}
示例10: doHelp
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected void doHelp(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
PortletContext context = getPortletContext();
PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(getHelpPage(request));
requestDispatcher.include(request, response);
}
示例11: doView
import javax.portlet.PortletContext; //导入方法依赖的package包/类
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
response.setContentType("text/html");
PortletContext context = getPortletContext();
PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(VIEW_PAGE);
requestDispatcher.include(request, response);
}
示例12: doEdit
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
response.setContentType("text/html");
PortletContext context = getPortletContext();
PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(EDIT_PAGE);
requestDispatcher.include(request, response);
}
示例13: doHelp
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected void doHelp(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
response.setContentType("text/html");
PortletContext context = getPortletContext();
PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(HELP_PAGE);
requestDispatcher.include(request, response);
}
示例14: include
import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected void include(String path, PortletRequest portletRequest,
PortletResponse portletResponse) throws IOException,
PortletException {
PortletContext portletContext = getPortletContext();
PortletRequestDispatcher portletRequestDispatcher = portletContext
.getRequestDispatcher(path);
if (portletRequestDispatcher == null) {
_log.error(path + " is not a valid include");
} else {
portletRequestDispatcher.include(portletRequest, portletResponse);
}
}