Java Code Examples for javax.portlet.RenderResponse#setContentType()

The following examples show how to use javax.portlet.RenderResponse#setContentType() . 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: AddlFilterTests_SPEC2_20_Event_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 {

  JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();

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

  if (portletReq.getParameter("tr12") != null && portletReq.getParameter("tr12").equals("true")) {
    TestResult tr12 = tcd.getTestResultFailed(V2ADDLFILTERTESTS_SPEC2_20_EVENT_FILTERWRAPPER4);
    tr12.setTcSuccess(true);
    tr12.writeTo(writer);
  }

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

}
 
Example 2
Source File: HeaderPortlet.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 {
   
   if (isDebug) {
      StringBuilder txt = new StringBuilder(128);
      txt.append("Rendering. ");
      txt.append("RENDER_PART: ");
      txt.append((String)req.getAttribute(PortletRequest.RENDER_PART));
      logger.debug(txt.toString());
   }

   resp.setContentType("text/html");

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

}
 
Example 3
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 4
Source File: DispatcherReqRespTests4_SPEC2_19_IncludeServletEventResponse_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>DispatcherReqRespTests4_SPEC2_19_IncludeServletEventResponse_event</p>\n");

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

}
 
Example 5
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 6
Source File: DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventResponse_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>DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventResponse_event</p>\n");

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

}
 
Example 7
Source File: DispatcherTests3S_SPEC2_19_ForwardJSPEvent_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_ForwardJSPEvent_event</p>\n");

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

   if (msg != null) {
      portletReq.getPortletSession().removeAttribute(
            RESULT_ATTR_PREFIX + V2DISPATCHERTESTS3S_SPEC2_19_FORWARDJSPEVENT_DISPATCH4, APPLICATION_SCOPE);
   } else {
      msg = "Not ready. click test case link.";
   }
   writer.write("<p>" + msg + "</p>\n");

}
 
Example 8
Source File: AddlRequestTests_SPEC2_11_EventReq_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>AddlRequestTests_SPEC2_11_EventReq_event</p>\n");

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

}
 
Example 9
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private void sendToJSP(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: 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 11
Source File: AddlPortletTests_SPEC2_15_Event_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>AddlPortletTests_SPEC2_15_Event_event</p>\n");

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

}
 
Example 12
Source File: TestPortlet.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Serves up the <code>edit</code> mode. This method dispatches the request
 * and response to the edit JSP page (<code>/jsp/edit.jsp</code>).
 * @param request  the portlet request.
 * @param response  the portlet response.
 */
protected void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
    response.setContentType("text/html");
    PortletRequestDispatcher dispatcher = getPortletContext()
            .getRequestDispatcher("/jsp/edit.jsp");
    dispatcher.include(request, response);
}
 
Example 13
Source File: AnnotationTests_ProcessEvent_ApiEvent_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>AnnotationTests_ProcessEvent_ApiEvent_event</p>\n");

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

}
 
Example 14
Source File: DispatcherTests4_SPEC2_19_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>DispatcherTests4_SPEC2_19_IncludeJSPEvent_event</p>\n");

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

}
 
Example 15
Source File: RenderStateTests_SPEC2_12_MutableRenderState2.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();

   PortletSession ps = portletReq.getPortletSession();
   String msg = (String) ps.getAttribute(Constants.RESULT_ATTR_PREFIX + "RenderStateTests_SPEC2_12_MutableRenderState2");
   ps.removeAttribute(Constants.RESULT_ATTR_PREFIX + "RenderStateTests_SPEC2_12_MutableRenderState2");

   if (msg != null && msg.length() > 0) {
      writer.write("<p>" + msg + "</p>\n");
   }
   
   /*
    * TestCase:
    * V3RenderStateTests_SPEC2_12_MutableRenderState_getRenderParameters3
    */
   /*
    * Details:
    * "If no render parameters are available, the object will be empty."
    */
   {
      ActionURL actionURL = portletResp.createActionURL();
      MutableActionParameters mutableActionParams = actionURL
            .getActionParameters();
      mutableActionParams.clear();
      TestButton tb = new TestButton(
            V3RENDERSTATETESTS_SPEC2_12_MUTABLERENDERSTATE_GETRENDERPARAMETERS3,
            actionURL);
      tb.writeTo(writer);
   }

}
 
Example 16
Source File: DispatcherTests5_SPEC2_19_IncThenForwardServletEvent_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>DispatcherTests5_SPEC2_19_IncThenForwardServletEvent_event</p>\n");

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

}
 
Example 17
Source File: PartialActionPortlet.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-pap.jsp");
   rd.include(req, resp);

}
 
Example 18
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private void sendToJSP(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 19
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
	
	response.setContentType("text/html");
	PrintWriter out = response.getWriter();
	String title = getTitleString(request);
	if ( title != null ) response.setTitle(title);

	Context context = new VelocityContext();
	context.put("tlang", rb);
	context.put("validator", formattedText);
	sendAlert(request,context);

	PortletURL url = response.createActionURL();
	context.put("actionUrl", url.toString());
	context.put("doCancel", "sakai.cancel");
	context.put("doUpdate", "sakai.update");

	// get current site
	Placement placement = ToolManager.getCurrentPlacement();
	String siteId = "";

	// find the right LTIContent object for this page
	String source = placement.getPlacementConfig().getProperty(SOURCE);
	Long key = getContentIdFromSource(source);
	if ( key == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find content id placement={} source={}", placement.getId(), source);
		return;
	}

	Map<String, Object> content = m_ltiService.getContent(key, placement.getContext());
	if ( content == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find content item placement={} key={}", placement.getId(), key);
		return;
	}

	// attach the ltiToolId to each model attribute, so that we could have the tool configuration page for multiple tools
	String foundLtiToolId = content.get(m_ltiService.LTI_TOOL_ID).toString();
	Map<String, Object> tool = m_ltiService.getTool(Long.valueOf(foundLtiToolId), placement.getContext());
	if ( tool == null ) {
		out.println(rb.getString("get.info.notconfig"));
		log.warn("Cannot find tool placement={} key={}", placement.getId(), foundLtiToolId);
		return;
	}

	String[] contentToolModel = m_ltiService.getContentModelIfConfigurable(Long.valueOf(foundLtiToolId), placement.getContext());
	if (contentToolModel != null) {
		String formInput = m_ltiService.formInput(content, contentToolModel);
		context.put("formInput", formInput);
	} else {
		String noCustomizations = rb.getString("gen.info.nocustom");
		context.put("noCustomizations", noCustomizations);
	}
	
	vHelper.doTemplate(vengine, "/vm/edit.vm", context, out);
}
 
Example 20
Source File: ColorSelPortlet.java    From portals-pluto with Apache License 2.0 3 votes vote down vote up
protected void doView(RenderRequest req, RenderResponse resp)
         throws PortletException, IOException {

      
      resp.setContentType("text/html");

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