Java Code Examples for javax.portlet.PortletContext#getRequestDispatcher()

The following examples show how to use javax.portlet.PortletContext#getRequestDispatcher() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DispatcherRenderParameterTest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: DispatcherRenderParameterTest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: DispatcherRenderParameterTest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: DispatcherRenderParameterTest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: PortletUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * 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");
	}
}
 
Example 6
Source File: GenericPlutoPortlet.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
    PortletContext context = getPortletContext();
    PortletRequestDispatcher requestDispatcher =
    		context.getRequestDispatcher(getViewPage());
    requestDispatcher.include(request, response);
}
 
Example 7
Source File: JSPHelper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
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);
		}
	}
}
 
Example 8
Source File: JSPHelper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
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);
		}
	}
}
 
Example 9
Source File: JSPHelper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
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);
		}
	}
}
 
Example 10
Source File: AboutPortlet.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: AboutPortlet.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: AboutPortlet.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 13
Source File: GenericPlutoPortlet.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
protected void doHelp(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
	PortletContext context = getPortletContext();
	PortletRequestDispatcher requestDispatcher =
			context.getRequestDispatcher(getHelpPage(request));
	requestDispatcher.include(request, response);
}
 
Example 14
Source File: GenericPlutoPortlet.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
protected void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
    PortletContext context = getPortletContext();
    PortletRequestDispatcher requestDispatcher =
    		context.getRequestDispatcher(getEditPage());
    requestDispatcher.include(request, response);
}
 
Example 15
Source File: DispatcherRequestTest.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 16
Source File: JSPHelper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
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);
		}
	}
}
 
Example 17
Source File: JSPHelper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
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);
		}
	}
}
 
Example 18
Source File: JSPHelper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
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);
		}
	}
}