javax.portlet.RenderResponse Java Examples

The following examples show how to use javax.portlet.RenderResponse. 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_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 #2
Source File: DispatcherTests4_SPEC2_19_ForwardJSPRender.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);

   portletResp.getWriter();

   // Prereq for: V2DispatcherTests4_SPEC2_19_ForwardJSPRender_invoke3
   portletReq = new RenderRequestWrapper(portletReq);
   portletResp = new RenderResponseWrapper(portletResp);

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherTests4_SPEC2_19_ForwardJSPRender" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
Example #3
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 #4
Source File: DispatcherTests4_SPEC2_19_IncludeServletResource.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_IncludeServletResource\">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_IncludeServletResource\").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 #5
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 #6
Source File: PortletWebRequestTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testNativeRequest() {
	MockRenderRequest portletRequest = new MockRenderRequest();
	MockRenderResponse portletResponse = new MockRenderResponse();
	PortletWebRequest request = new PortletWebRequest(portletRequest, portletResponse);
	assertSame(portletRequest, request.getNativeRequest());
	assertSame(portletRequest, request.getNativeRequest(PortletRequest.class));
	assertSame(portletRequest, request.getNativeRequest(RenderRequest.class));
	assertSame(portletRequest, request.getNativeRequest(MockRenderRequest.class));
	assertNull(request.getNativeRequest(MultipartRequest.class));
	assertSame(portletResponse, request.getNativeResponse());
	assertSame(portletResponse, request.getNativeResponse(PortletResponse.class));
	assertSame(portletResponse, request.getNativeResponse(RenderResponse.class));
	assertSame(portletResponse, request.getNativeResponse(MockRenderResponse.class));
	assertNull(request.getNativeResponse(MultipartRequest.class));
}
 
Example #7
Source File: DispatcherTests6_SPEC2_19_FwdThenForwardServletRender.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);

   portletResp.getWriter();

   // Multilevel forward / include
   portletReq.setAttribute(ATTR_DISPATCH_ACTION, "forward");
   String targ = SERVLET_PREFIX + "DispatcherTests6_SPEC2_19_FwdThenForwardServletRender_servlet" + EXTRA_PATH + "?"
         + QUERY_STRING;
   portletReq.setAttribute(ATTR_DISPATCH_TARGET, targ);

   // Now do the actual dispatch
   String target = "/IncluderForwarderServlet" + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
Example #8
Source File: DispatcherTests_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>DispatcherTests_SPEC2_19_ForwardServletEvent_event</p>\n");

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

   PortletURL rurl = portletResp.createRenderURL();
   rurl.setParameter("qparm2", "renderVal2");
   TestSetupLink tl1 = new TestSetupLink(V2DISPATCHERTESTS_SPEC2_19_FORWARDSERVLETEVENT_DISPATCH2, rurl);
   tl1.writeTo(writer);

}
 
Example #9
Source File: AnnotationPortletAppConfigOverrideTests_SPEC1_28_PublicRenderParameters1.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: V3AnnotationPortletAppConfigOverrideTests_SPEC1_28_PublicRenderParameters1_declaringPRP2 */
   /* Details: "A public render parameters can be declared two times - once   */
   /* in @PortletApplication then again in deployment descriptor portlet.xml"    */
   {
      TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPCONFIGOVERRIDETESTS_SPEC1_28_PUBLICRENDERPARAMETERS1_DECLARINGPRP2);
      if(portletReq.getRenderParameters().isPublic("tr0_public")){
         result.setTcSuccess(true);
      } else {
         result.appendTcDetail("Failed because public render parameter tr0_public is not found.");
      }
      result.writeTo(writer);
   }

}
 
Example #10
Source File: DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceRequest.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_IncludeServletResourceRequest\">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_IncludeServletResourceRequest\").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 #11
Source File: DispatcherTests2_SPEC2_19_IncludeJSPEvent_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>DispatcherTests2_SPEC2_19_IncludeJSPEvent_event</p>\n");

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

   /* TestCase: V2DispatcherTests2_SPEC2_19_IncludeJSPEvent_dispatch2 */
   /* Details: "Parameters specified in the query strings must be */
   /* aggregated with the portlet render parameters" */
   PortletURL urlEvent = ((MimeResponse) portletResp).createRenderURL();
   urlEvent.setParameter("qparm2", "renderVal2");
   TestSetupLink tlEvent = new TestSetupLink(V2DISPATCHERTESTS2_SPEC2_19_INCLUDEJSPEVENT_DISPATCH2, urlEvent);
   tlEvent.writeTo(writer);

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

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

      /* TestCase: V3AnnotationPortletApplicationConfigTests_SPEC1_28_PortletContainerRuntimeOptions_declaringPCRO1 */
      /* Details: "Portlet container runtime options may be declared in the         */
      /* @PortletApplication annotation using @RuntimeOption annotation."           */
      {
         TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPLICATIONCONFIGTESTS_SPEC1_28_PORTLETCONTAINERRUNTIMEOPTIONS_DECLARINGPCRO1);
         Map<String, String[]> runtimeOptions = portletConfig.getContainerRuntimeOptions();
         if (isRuntimeOptionsCorrect(runtimeOptions)) {
            result.setTcSuccess(true);
         }
         result.writeTo(writer);
      }

   }
 
Example #13
Source File: DispatcherReqRespTests3_SPEC2_19_IncludeJSPRenderRequest.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: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPRenderRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPRenderRequest_getAttribute", "Value1");

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

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPRenderRequest" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.include(portletReq, portletResp);
}
 
Example #14
Source File: WelcomePortlet.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
	response.setContentType("text/html");
	PrintWriter out = response.getWriter();
	out.println("<h1>Welcome to the Pet Portal!</h1>");
	if(request.getWindowState().equals(WindowState.MAXIMIZED)) {
		out.println("<p>This portlet delegates to an existing JSR-168 portlet via a HandlerAdapter</p>");
		out.println("<p>(see WEB-INF/context/welcome-context.xml for the details).</p>");
		out.println("<p>Portlet Name: " + this.getPortletName() + "</p>");
		out.println("<p>Init Parameters:</p><ul>");
		for (Enumeration e = this.getInitParameterNames(); e.hasMoreElements();) {
				String name = (String)e.nextElement();
				out.println("<li>" + name + " = " + this.getInitParameter(name) + "</li>");
		}
		out.println("</ul>");
		out.println("<p>Your Locale: " + request.getLocale().toString() + "</p>");
	}
}
 
Example #15
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 #16
Source File: PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr39.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 {
  ResourceURL resurl = portletResp.createResourceURL();
  resurl.setCacheability(FULL);
  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);
  PrintWriter writer = portletResp.getWriter();
  
  writer.write("<div id=\"PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr39\">no resource output.</div>\n");
  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(\"PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr39\").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 #17
Source File: PortletConfigTests_ConfigInit.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@RenderMethod(portletNames = "PortletConfigTests_ConfigInit")
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

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

   PrintWriter writer = portletResp.getWriter();

   ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();

   /* TestCase: PortletConfigTests_Config_init */
   /* Details: "The PortletConfig object is passed to an annotated */
   /* init method" */
   {
      TestResult result = tcd.getTestResultFailed(V3PORTLETCONFIGTESTS_CONFIG_INIT);
      if (portletConfig != null) {
         result.setTcSuccess(true);
      }
      result.writeTo(writer);
   }

}
 
Example #18
Source File: DispatcherTests3S_SPEC2_19_IncludeServletEvent.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: V2DispatcherTests3S_SPEC2_19_IncludeServletEvent_dispatch4 */
   /* Details: "The parameters associated with a request dispatcher are */
   /* scoped only for the duration of the include or forward call" */
   {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb = new TestButton(V2DISPATCHERTESTS3S_SPEC2_19_INCLUDESERVLETEVENT_DISPATCH4, aurl);
      tb.writeTo(writer);
   }

}
 
Example #19
Source File: DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceResponse.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=\"DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceResponse\">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(\"DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceResponse\").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 #20
Source File: AnnotationPortletApplicationConfigTests_SPEC1_28_PublicRenderParameters.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_PublicRenderParameters_declaringPRP1 */
   /* Details: "A public render parameters may be declared in the                */
   /* @PortletApplication annotation using @PublicRenderParameterDefinition      */
   /* annotation."                                                               */
   {
      TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETAPPLICATIONCONFIGTESTS_SPEC1_28_PUBLICRENDERPARAMETERS_DECLARINGPRP1);
      if(portletReq.getRenderParameters().isPublic("tr0_public")){
         result.setTcSuccess(true);
      } else {
         result.appendTcDetail("Failed because tr0_public public render parameter is not found.");
      }
      result.writeTo(writer);
   }

}
 
Example #21
Source File: DispatcherTests_SPEC2_19_IncludeServletEvent_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>DispatcherTests_SPEC2_19_IncludeServletEvent_event</p>\n");

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

   PortletURL rurl = portletResp.createRenderURL();
   rurl.setParameter("qparm2", "renderVal2");
   TestSetupLink tl1 = new TestSetupLink(V2DISPATCHERTESTS_SPEC2_19_INCLUDESERVLETEVENT_DISPATCH2, rurl);
   tl1.writeTo(writer);

}
 
Example #22
Source File: RequestTests_EventRequest_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 {
   
   LOGGER.trace("event companion render");

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

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

}
 
Example #23
Source File: AnnotationPortletConfigTests_SPEC2_28_EventDeclaration.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: V3AnnotationPortletConfigTests_SPEC2_28_EventDeclaration_eventEventDeclaration1 */
   /* Details: "An event can be fired from another event method configured with  */
   /* @EventMethod annotation - publishingEvents attribute."                     */
   if(renderParams.getValue("tr0")!=null && renderParams.getValue("tr0").equals("true")){
      TestResult result = tcd.getTestResultFailed(V3ANNOTATIONPORTLETCONFIGTESTS_SPEC2_28_EVENTDECLARATION_EVENTEVENTDECLARATION1);
      result.setTcSuccess(true);
      result.writeTo(writer);
   } else {
      ActionURL aurl = portletResp.createActionURL();
      TestButton tb = new TestButton(
            V3ANNOTATIONPORTLETCONFIGTESTS_SPEC2_28_EVENTDECLARATION_EVENTEVENTDECLARATION1,
            aurl);
      tb.writeTo(writer);
   }

}
 
Example #24
Source File: DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest.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: V2DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest_getAttribute", "Value1");

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

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.include(portletReq, portletResp);
}
 
Example #25
Source File: SigTestsEvent_PortletRequest_SIGEvent_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>SigTestsEvent_PortletRequest_SIGEvent_event</p>\n");

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

}
 
Example #26
Source File: DispatcherTests4_SPEC2_19_ForwardJSPEvent_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>DispatcherTests4_SPEC2_19_ForwardJSPEvent_event</p>\n");

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

}
 
Example #27
Source File: ComplexPortletApplicationContext.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response)
	throws PortletException, IOException {
	if (!Locale.CANADA.equals(LocaleContextHolder.getLocale())) {
		throw new PortletException("Incorrect Locale in LocaleContextHolder");
	}
	response.getWriter().write("locale-ok");
	return null;
}
 
Example #28
Source File: ImageSelPortlet.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
protected void doView(RenderRequest req, RenderResponse resp)
      throws PortletException, IOException {
   
   if (logger.isDebugEnabled()) {
      logger.debug(this.getClass().getName(), "doView", "Entry");
   }
   
   resp.setContentType("text/html");

   PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
         "/WEB-INF/jsp/view-isp.jsp");
   rd.include(req, resp);

}
 
Example #29
Source File: FilterTests_FilterChain_ApiResourceFilter.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 {

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

  PrintWriter writer = portletResp.getWriter();

  writer
      .write("<div id=\"FilterTests_FilterChain_ApiResourceFilter\">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(\"FilterTests_FilterChain_ApiResourceFilter\").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 #30
Source File: ResourceURLTag286.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a resourceURL.
 * 
 * @param portletResponse
 * @return a resourceURL
 * @throws JspException
 */
protected ResourceURL createResourceURL(PortletResponse portletResponse) throws JspException{
	ResourceURL result = null;
	if(portletResponse instanceof RenderResponse){
   		result = ((RenderResponse)portletResponse).createResourceURL();	
   	}
   	else if(portletResponse instanceof ResourceResponse){
   		result = ((ResourceResponse)portletResponse).createResourceURL();
   	}	
   	else{
   		throw new JspException();
   	}
	return result;
}