javax.portlet.RenderRequest Java Examples

The following examples show how to use javax.portlet.RenderRequest. 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: DispatcherTests6_SPEC2_19_FwdThenForwardServletResource.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherTests6_SPEC2_19_FwdThenForwardServletResource\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherTests6_SPEC2_19_FwdThenForwardServletResource\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example #2
Source File: AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   PrintWriter writer = portletResp.getWriter();
   ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();
   
   RenderParameters renderParams = portletReq.getRenderParameters();

   /* TestCase: V3AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1_declaringEvents3 */
   /* Details: "Same event declared in @PortletApplication and deployment
    *  descriptor portlet.xml is overridden by deployment descriptor"       */
   if(renderParams.getValue("tr0")!=null && renderParams.getValue("tr0").equals("true")){
      TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPCONFIGOVERRIDETESTS_SPEC1_28_EVENTCONFIGURATION1_DECLARINGEVENTS3);
      result.setTcSuccess(true);
      result.writeTo(writer);
   } else {
      ActionURL aurl = portletResp.createActionURL();
      TestButton tb = new TestButton(
            V3ANNOTATIONPORTLETAPPCONFIGOVERRIDETESTS_SPEC1_28_EVENTCONFIGURATION1_DECLARINGEVENTS3,
            aurl);
      tb.writeTo(writer);
   }

}
 
Example #3
Source File: DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceResponse.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceResponse\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceResponse\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example #4
Source File: DispatcherReqRespTests2_SPEC2_19_ForwardServletEventResponse_event.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {
   

   portletResp.setContentType("text/html");
   PrintWriter writer = portletResp.getWriter();
   writer.write("<h3>Event Companion Portlet </h3>\n");
   writer.write("<p>DispatcherReqRespTests2_SPEC2_19_ForwardServletEventResponse_event</p>\n");

   String msg = (String) portletReq.getPortletSession()
         .getAttribute(RESULT_ATTR_PREFIX + "DispatcherReqRespTests2_SPEC2_19_ForwardServletEventResponse", APPLICATION_SCOPE);
   msg = (msg==null) ? "Not ready. click test case link." : msg;
   writer.write("<p>" + msg + "</p>\n");

}
 
Example #5
Source File: DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceResponse.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceResponse\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceResponse\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example #6
Source File: ResponseTests_StateAwareResponse_ApiEvent_event.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   portletResp.setContentType("text/html");
   PrintWriter writer = portletResp.getWriter();
   writer.write("<h3>Event Companion Portlet </h3>\n");
   writer.write("<p>ResponseTests_StateAwareResponse_ApiEvent_event</p>\n");

   String msg = (String) portletReq.getPortletSession().getAttribute(
         RESULT_ATTR_PREFIX + "ResponseTests_StateAwareResponse_ApiEvent",
         APPLICATION_SCOPE);
   msg = (msg == null) ? "Not ready. click test case link." : msg;
   writer.write("<p>" + msg + "</p>\n");

}
 
Example #7
Source File: AnnotationMethodHandlerAdapter.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private String determineDefaultPhase(Method handlerMethod) {
	if (void.class != handlerMethod.getReturnType()) {
		return PortletRequest.RENDER_PHASE;
	}
	for (Class<?> argType : handlerMethod.getParameterTypes()) {
		if (ActionRequest.class.isAssignableFrom(argType) || ActionResponse.class.isAssignableFrom(argType) ||
				InputStream.class.isAssignableFrom(argType) || Reader.class.isAssignableFrom(argType)) {
			return PortletRequest.ACTION_PHASE;
		}
		else if (RenderRequest.class.isAssignableFrom(argType) || RenderResponse.class.isAssignableFrom(argType) ||
				OutputStream.class.isAssignableFrom(argType) || Writer.class.isAssignableFrom(argType)) {
			return PortletRequest.RENDER_PHASE;
		}
		else if (ResourceRequest.class.isAssignableFrom(argType) || ResourceResponse.class.isAssignableFrom(argType)) {
			return PortletRequest.RESOURCE_PHASE;
		}
		else if (EventRequest.class.isAssignableFrom(argType) || EventResponse.class.isAssignableFrom(argType)) {
			return PortletRequest.EVENT_PHASE;
		}
	}
	return "";
}
 
Example #8
Source File: SimpleRSSPortlet.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Helper to handle error messages
 * @param messageKey	Message bundle key
 * @param headingKey	optional error heading message bundle key, if not specified, the general one is used
 * @param link			if the message text is to be linked, what is the href?
 * @param request
 * @param response
 */
private void doError(String messageKey, String headingKey, String link, RenderRequest request, RenderResponse response){
	
	//message
	request.setAttribute("errorMessage", Messages.getString(messageKey));
	
	//optional heading
	if(StringUtils.isNotBlank(headingKey)){
		request.setAttribute("errorHeading", Messages.getString(headingKey));
	} else {
		request.setAttribute("errorHeading", Messages.getString("error.heading.general"));
	}

	if(StringUtils.isNotBlank(link)){
		request.setAttribute("errorLink", link);
	}

	//dispatch
	try {
		dispatch(request, response, errorUrl);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
}
 
Example #9
Source File: DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventResponse_event.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {
   

   portletResp.setContentType("text/html");
   PrintWriter writer = portletResp.getWriter();
   writer.write("<h3>Event Companion Portlet </h3>\n");
   writer.write("<p>DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventResponse_event</p>\n");

   String msg = (String) portletReq.getPortletSession()
         .getAttribute(RESULT_ATTR_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventResponse", APPLICATION_SCOPE);
   msg = (msg==null) ? "Not ready. click test case link." : msg;
   writer.write("<p>" + msg + "</p>\n");

}
 
Example #10
Source File: AnnotationPortletConfigTests_SPEC2_28_PortletDependency.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   PrintWriter writer = portletResp.getWriter();
   ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();

   /* TestCase: V3AnnotationPortletConfigTests_SPEC2_28_PortletDependency_declaringDependency1 */
   /* Details: "Portlet dependency may be declared using @Dependency annotation  */
   /* in @PortletConfiguration annotation."                                      */
   {
      TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETCONFIGTESTS_SPEC2_28_PORTLETDEPENDENCY_DECLARINGDEPENDENCY1);
      result.writeTo(writer);
   }
   writer.write("<script type='text/javascript'>");
   writer.write("document.addEventListener('DOMContentLoaded', function(event) {");
   writer.write("  if (typeof window.portlet != 'undefined') { ");
   writer.write("    document.getElementById('V3AnnotationPortletConfigTests_SPEC2_28_PortletDependency_declaringDependency1-result').innerHTML = 'Test Succeeded';");
   writer.write("  }");
   writer.write("});");
   writer.write("</script>");

}
 
Example #11
Source File: PortletTests_GenericPortlet_ApiRender.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
protected void doDispatch(RenderRequest req, RenderResponse resp)
      throws PortletException, IOException {

   super.doDispatch(req, resp);

   PrintWriter writer = resp.getWriter();

   JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

   /* TestCase: V2PortletTests_GenericPortlet_ApiRender_doDispatch1 */
   /* Details: "Method doDispatch(RenderRequest, RenderResponse): If */
   /* overridden, is called when markup is to be generated" */
   TestResult tr6 = tcd.getTestResultFailed(
         V2PORTLETTESTS_GENERICPORTLET_APIRENDER_DODISPATCH1);
   tr6.setTcSuccess(true);
   tr6.writeTo(writer);

}
 
Example #12
Source File: DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceRequest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceRequest\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceRequest\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example #13
Source File: AnnotationTests_RenderMode_ApiRender.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@RenderMode(name = "VIEW")
public void newRender(RenderRequest req, RenderResponse resp)
    throws PortletException, IOException {
  PrintWriter writer = resp.getWriter();
  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();


  /* TestCase: V2AnnotationTests_RenderMode_ApiRender_name */
  /* Details: "Method name(): On a render request, the method is */
  /* executed if the portlet mode matches the name field" */

  TestResult tr0 = tcd.getTestResultFailed(V2ANNOTATIONTESTS_RENDERMODE_APIRENDER_NAME);
  tr0.setTcSuccess(true);
  tr0.writeTo(writer);

}
 
Example #14
Source File: DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceResponse.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceResponse\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceResponse\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example #15
Source File: DispatcherTests4_SPEC2_19_ForwardJSPEvent.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   /* TestCase: V2DispatcherTests4_SPEC2_19_ForwardJSPEvent_invoke3 */
   /* Details: "Parameters to the forward method for a target servlet */
   /* can be wrapped request and response classes from the portlet */
   /* lifecyle method initiating the include" */
   {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb = new TestButton(V2DISPATCHERTESTS4_SPEC2_19_FORWARDJSPEVENT_INVOKE3, aurl);
      tb.writeTo(writer);
   }

}
 
Example #16
Source File: DispatcherTests3S_SPEC2_19_ForwardServletEvent_event.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   portletResp.setContentType("text/html");
   PrintWriter writer = portletResp.getWriter();
   writer.write("<h3>Event Companion Portlet </h3>\n");
   writer.write("<p>DispatcherTests3S_SPEC2_19_ForwardServletEvent_event</p>\n");

   String msg = (String) portletReq.getPortletSession().getAttribute(
         RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_FORWARDSERVLETEVENT_DISPATCH4, APPLICATION_SCOPE);

   if (msg != null) {
      portletReq.getPortletSession().removeAttribute(
            RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_FORWARDSERVLETEVENT_DISPATCH4, APPLICATION_SCOPE);
   }

   msg = (msg == null) ? "Not ready. click test case link." : msg;
   writer.write("<p>" + msg + "</p>\n");

}
 
Example #17
Source File: DispatcherTests4_SPEC2_19_ForwardServletResource.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherTests4_SPEC2_19_ForwardServletResource\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherTests4_SPEC2_19_ForwardServletResource\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example #18
Source File: DispatcherTests6_SPEC2_19_FwdThenIncludeServletResource.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherTests6_SPEC2_19_FwdThenIncludeServletResource\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherTests6_SPEC2_19_FwdThenIncludeServletResource\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example #19
Source File: AbstractController.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
	// If the portlet is minimized and we don't want to render then return null.
	if (WindowState.MINIMIZED.equals(request.getWindowState()) && !this.renderWhenMinimized) {
		return null;
	}

	// Delegate to PortletContentGenerator for checking and preparing.
	checkAndPrepare(request, response);

	// Execute in synchronized block if required.
	if (this.synchronizeOnSession) {
		PortletSession session = request.getPortletSession(false);
		if (session != null) {
			Object mutex = PortletUtils.getSessionMutex(session);
			synchronized (mutex) {
				return handleRenderRequestInternal(request, response);
			}
		}
	}

	return handleRenderRequestInternal(request, response);
}
 
Example #20
Source File: AnnotationPortletApplicationConfigTests_SPEC1_28_DefaultNamespaceURI.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   PrintWriter writer = portletResp.getWriter();
   ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();

   /* TestCase: V3AnnotationPortletApplicationConfigTests_SPEC1_28_DefaultNamespaceURI_declaringDefaultNamespaceURI1 */
   /* Details: "DefaultNamespaceURI may be declared in the @PortletApplication   */
   /* annotation."                                                               */
   {
      TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPLICATIONCONFIGTESTS_SPEC1_28_DEFAULTNAMESPACEURI_DECLARINGDEFAULTNAMESPACEURI1);
      if(portletConfig.getDefaultNamespace().equals("http://www.apache.org/portals/pluto/portlet-tck_3.0")){
         result.setTcSuccess(true);
      } else {
         result.appendTcDetail("Failed because default namespace URI is not http://www.apache.org/portals/pluto/portlet-tck_3.0 but "+portletConfig.getDefaultNamespace());
      }
      result.writeTo(writer);
   }

}
 
Example #21
Source File: DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
Example #22
Source File: DispatcherTests_SPEC2_19_ForwardServletResource.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherTests_SPEC2_19_ForwardServletResource\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherTests_SPEC2_19_ForwardServletResource\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example #23
Source File: PortletTests_GenericPortlet_ApiRender.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
protected void doView(RenderRequest req, RenderResponse resp)
      throws PortletException, IOException {

   PrintWriter writer = resp.getWriter();

   JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

   /* TestCase: V2PortletTests_GenericPortlet_ApiRender_doView1 */
   /* Details: "Method doView(RenderRequest, RenderResponse): If */
   /* overridden, is called when a render request in view mode occurs" */
   TestResult tr7 = tcd.getTestResultFailed(
         V2PORTLETTESTS_GENERICPORTLET_APIRENDER_DOVIEW1);
   tr7.setTcSuccess(true);
   tr7.writeTo(writer);

}
 
Example #24
Source File: WrapperTests_EventRequestWrapper_ApiEvent_event.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   portletResp.setContentType("text/html");
   PrintWriter writer = portletResp.getWriter();
   writer.write("<h3>Event Companion Portlet </h3>\n");
   writer.write("<p>WrapperTests_EventRequestWrapper_ApiEvent_event</p>\n");

   String msg = (String) portletReq.getPortletSession().getAttribute(
         RESULT_ATTR_PREFIX + "WrapperTests_EventRequestWrapper_ApiEvent",
         APPLICATION_SCOPE);
   msg = (msg == null) ? "Not ready. click test case link." : msg;
   writer.write("<p>" + msg + "</p>\n");

}
 
Example #25
Source File: HeaderPortletTests_SPEC14_HeaderReq.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException, IOException {

   PrintWriter writer = renderResponse.getWriter();
   String msg = (String) renderRequest.getAttribute(
         RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC14_HeaderReq");
   writer.write("<p>" + msg + "</p>\n");
   renderRequest.removeAttribute(
         RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC14_HeaderReq");

}
 
Example #26
Source File: RenderStateTests_SPEC1_12_RenderState2.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   PrintWriter writer = portletResp.getWriter();
   ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();

   /*
    * TestCase: V3RenderStateTests_SPEC1_12_RenderState_getRenderParameters3
    */
   /*
    * Details:
    * "If no render parameters are available, the object will be empty."
    */
   {
      TestResult result = tcd.getTestResultFailed(
            V3RENDERSTATETESTS_SPEC1_12_RENDERSTATE_GETRENDERPARAMETERS3);
      if (portletReq.getRenderParameters().isEmpty()) {
         result.setTcSuccess(true);
      } else {
         result.appendTcDetail(
               "Failed because render parameters are not empty. RenderState.getRenderParameters() method returned "
                     + portletReq.getRenderParameters().size()
                     + " render parameters.");
      }
      result.writeTo(writer);
   }

}
 
Example #27
Source File: SimplePortletHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public ModelAndView handleRender(RenderRequest request, RenderResponse response, Object handler)
		throws Exception {

	((Portlet) handler).render(request, response);
	return null;
}
 
Example #28
Source File: PortletTagLibraryTests_SPEC2_26_IncludeJSPEvent_event.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

  portletResp.setContentType("text/html");
  PrintWriter writer = portletResp.getWriter();
  writer.write("<h3>Event Companion Portlet </h3>\n");
  writer.write("<p>PortletTagLibraryTests_SPEC2_26_IncludeJSPEvent_event</p>\n");

  String msg = (String) portletReq.getPortletSession().getAttribute(
      RESULT_ATTR_PREFIX + "PortletTagLibraryTests_SPEC2_26_IncludeJSPEvent", APPLICATION_SCOPE);
  msg = (msg == null) ? "Not ready. click test case link." : msg;
  writer.write("<p>" + msg + "</p>\n");

}
 
Example #29
Source File: FilterTests_EventFilter_ApiEventFilter_event2.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  portletResp.setContentType("text/html");
  PrintWriter writer = portletResp.getWriter();

  /* TestCase: V2FilterTests_EventFilter_ApiEventFilter_doFilterBlock */
  /* Details: "If the doFilter(EventRequest, EventResponse, */
  /* FilterChain): method does not invoke the next filter, processEvent */
  /* is not called" */
  if (portletReq.getParameter("tr5_success") != null
      && portletReq.getParameter("tr5_success").equals("true")) {
    TestResult tr5 =
        tcd.getTestResultFailed(V2FILTERTESTS_EVENTFILTER_APIEVENTFILTER_DOFILTERBLOCK);
    if (portletReq.getParameter("tr5") == null) {
      tr5.setTcSuccess(true);
    } else {
      tr5.appendTcDetail(
          "Failed because processEvent was executed which set the tr5 parameter value to "
              + portletReq.getParameter("tr5"));
    }
    tr5.writeTo(writer);
  }
}
 
Example #30
Source File: AddlFilterTests_SPEC2_20_Filter.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void doFilter(RenderRequest portletReq, RenderResponse portletResp, FilterChain chain)
    throws IOException, PortletException {
  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);
  JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();

  /* TestCase: V2AddlFilterTests_SPEC2_20_Render_filterWrapper6 */
  /* Details: "An RENDER_PHASE filter can wrap the RenderResponse */
  /* object with a custom wrapper" */
  RenderResponseWrapper renderResp = new RenderResponseWrapper(portletResp);
  PrintWriter writer = renderResp.getWriter();
  TestResult tr12 = tcd.getTestResultFailed(V2ADDLFILTERTESTS_SPEC2_20_RENDER_FILTERWRAPPER6);
  tr12.setTcSuccess(true);
  tr12.writeTo(writer);

  // Create result objects for the tests

  /* TestCase: V2AddlFilterTests_SPEC2_20_Render_filterWrapper5 */
  /* Details: "An RENDER_PHASE filter can wrap the RenderRequest object */
  /* with a custom wrapper" */
  TestResult tr11 = tcd.getTestResultFailed(V2ADDLFILTERTESTS_SPEC2_20_RENDER_FILTERWRAPPER5);
  RenderRequestWrapper renderReq = new RenderRequestWrapper(portletReq);
  if (renderReq.getParameter("tr11") != null && renderReq.getParameter("tr11").equals("true")) {
    tr11.setTcSuccess(true);
  } else {
    tr11.appendTcDetail("Render Parameter tr11 is not found in the wrapper");
  }
  tr11.writeTo(writer);

  /* TestCase: V2AddlFilterTests_SPEC2_20_Render_filter3 */
  /* Details: "If the filter declaration specifies the */
  /* &lt;lifecycle&gt; tag value RENDER_PHASE, the */
  /* RenderFilter.doFilter method is called" */
  TestResult tr13 = tcd.getTestResultFailed(V2ADDLFILTERTESTS_SPEC2_20_RENDER_FILTER3);
  tr13.setTcSuccess(true);
  tr13.writeTo(writer);

  chain.doFilter(portletReq, portletResp);
}