Java Code Examples for javax.portlet.RenderResponse#createRenderURL()
The following examples show how to use
javax.portlet.RenderResponse#createRenderURL() .
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: PortletUrlBuilder.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
public String getRenderUrl(HttpServletRequest aHttpServletRequest, Map parameters) { logger.debug("IN"); RenderResponse renderResponse =(RenderResponse)aHttpServletRequest.getAttribute("javax.portlet.response"); PortletURL aPortletURL = renderResponse.createRenderURL(); if (parameters != null){ Iterator keysIt = parameters.keySet().iterator(); String paramName = null; Object paramValue = null; while (keysIt.hasNext()){ paramName = (String)keysIt.next(); paramValue = parameters.get(paramName); if (paramValue == null) { logger.warn("Parameter with name " + paramName + " has null value. This parameter will be not considered."); continue; } aPortletURL.setParameter(paramName, paramValue.toString()); } } String url = aPortletURL.toString(); logger.debug("OUT"); return url; }
Example 2
Source File: DispatcherTests_SPEC2_19_IncludeServletEvent_event.java From portals-pluto with Apache License 2.0 | 6 votes |
@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 3
Source File: DispatcherTests_SPEC2_19_ForwardServletEvent_event.java From portals-pluto with Apache License 2.0 | 6 votes |
@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 4
Source File: SimpleRSSPortlet.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Helper to get the URL to take us to a portlet mode. * This will end up in doDispatch. * * @param response * @return */ private String getPortletModeUrl(RenderResponse response, PortletMode mode) { PortletURL url = response.createRenderURL(); try { url.setPortletMode(mode); } catch (PortletModeException e) { log.error("Invalid portlet mode: " + mode); return null; } return url.toString(); }
Example 5
Source File: TestModule3_Portlet1.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { LOGGER.trace("render: Entry"); PrintWriter writer = response.getWriter(); PortletURL purl; TestLink tl; // Test: TestModule3_PublicRenderParameterTestDifferentPortletApplications // This portlet generates the link. The companion portlet displays the results. purl = response.createRenderURL(); purl.setParameter(TM3PRP0, TEST0); tl = new TestLink(TEST0, purl); tl.writeTo(writer); // Test: TestModule3_PublicRenderParameterTestDifferentQName // This portlet generates the link. The companion portlet displays the results. purl = response.createRenderURL(); purl.setParameter(TM3PRP0, TEST1); purl.setParameter(TM3PRP1, TM3PRP1); tl = new TestLink(TEST1, purl); tl.writeTo(writer); // Test: TestModule3_PublicRenderParameterTestDifferentIdentifier // This portlet generates the link. The companion portlet displays the results. purl = response.createRenderURL(); purl.setParameter(TM3PRP0, TEST2); purl.setParameter(TM3PRP2, TM3PRP2); tl = new TestLink(TEST2, purl); tl.writeTo(writer); }
Example 6
Source File: AddlRequestTests_SPEC2_11_Event_event.java From portals-pluto with Apache License 2.0 | 5 votes |
@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_Event_event</p>\n"); /* TestCase: V2AddlRequestTests_SPEC2_11_Event_parameters12 */ /* Details: "If a portlet receives an event that is the result of a */ /* client request targeted to another portlet in the portal page, the */ /* parameters should be the same parameters as of the previous render */ /* request from this client" */ if (portletReq.getParameter("tr3") == null) { PortletURL rurl = portletResp.createRenderURL(); rurl.setParameters(portletReq.getPrivateParameterMap()); rurl.setParameter("tr3", "true"); TestSetupLink tb = new TestSetupLink(V2ADDLREQUESTTESTS_SPEC2_11_EVENT_PARAMETERS12, rurl); tb.writeTo(writer); } String msg = (String) portletReq.getPortletSession() .getAttribute(RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_Event", APPLICATION_SCOPE) + (String) portletReq.getPortletSession().getAttribute( RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_Event_event", APPLICATION_SCOPE); msg = (msg.equals("nullnull")) ? "Not ready. click test case link." : msg; writer.write("<p>" + msg + "</p>\n"); }
Example 7
Source File: SimpleRSSPortlet.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Helper to get the URL to take us to a portlet mode. * This will end up in doDispatch. * * @param response * @return */ private String getPortletModeUrl(RenderResponse response, PortletMode mode) { PortletURL url = response.createRenderURL(); try { url.setPortletMode(mode); } catch (PortletModeException e) { log.error("Invalid portlet mode: " + mode); return null; } return url.toString(); }
Example 8
Source File: AddlEnvironmentTests_SPEC2_18_Sessions2.java From portals-pluto with Apache License 2.0 | 4 votes |
@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(); JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); // Create result objects for the tests /* TestCase: V2AddlEnvironmentTests_SPEC2_18_Sessions_scope2 */ /* Details: "The portlet container must not share the PortletSession */ /* object or the attributes stored in it among different portlet */ /* applications or among different user sessions" */ TestResult tr1 = tcd.getTestResultFailed(V2ADDLENVIRONMENTTESTS_SPEC2_18_SESSIONS_SCOPE2); String tr1_success = (String) portletReq.getPortletSession().getAttribute(Constants.RESULT_ATTR_PREFIX + "AddlEnvironmentTests_SPEC2_18_Sessions_tr1", PORTLET_SCOPE); if (tr1_success == null) { tr1.setTcSuccess(true); } else { tr1.appendTcDetail("Failed becuase AddlEnvironmentTests_SPEC2_18_Sessions_tr1 is found " + "even though it was saved by another portlet in PORTLET_SCOPE"); } tr1.writeTo(writer); /* TestCase: V2AddlEnvironmentTests_SPEC2_18_Sessions_scope3 */ /* Details: "Any object stored in the session using the */ /* APPLICATION_SCOPE is available to any portlet that belongs to the */ /* same portlet application and that handles a request in the same */ /* session" */ { String tc = portletReq.getParameter(BUTTON_PARAM_NAME); if (tc != null && tc.equals(V2ADDLENVIRONMENTTESTS_SPEC2_18_SESSIONS_SCOPE3)) { TestResult tr2 = tcd.getTestResultFailed(V2ADDLENVIRONMENTTESTS_SPEC2_18_SESSIONS_SCOPE3); String val = (String) portletReq.getPortletSession().getAttribute(V2ADDLENVIRONMENTTESTS_SPEC2_18_SESSIONS_SCOPE3, APPLICATION_SCOPE); if (val != null && val.equals("true")) { tr2.setTcSuccess(true); } else { StringBuilder txt = new StringBuilder(128); txt.append("Failed, Attribute ").append(V2ADDLENVIRONMENTTESTS_SPEC2_18_SESSIONS_SCOPE3).append(" value: "); txt.append((val == null) ? "null" : val); tr2.appendTcDetail(txt.toString()); } tr2.writeTo(writer); } else { PortletURL rurl = portletResp.createRenderURL(); rurl.setParameter(BUTTON_PARAM_NAME, V2ADDLENVIRONMENTTESTS_SPEC2_18_SESSIONS_SCOPE3); TestLink link = new TestLink(V2ADDLENVIRONMENTTESTS_SPEC2_18_SESSIONS_SCOPE3, rurl); link.writeTo(writer); } } /* TestCase: V2AddlEnvironmentTests_SPEC2_18_Sessions_scope4 */ /* Details: "Any Object stored in the session using the PORTLET_SCOPE */ /* must be available to the portlet during requests for the same */ /* portlet window that stored the object" */ TestResult tr3 = tcd.getTestResultFailed(V2ADDLENVIRONMENTTESTS_SPEC2_18_SESSIONS_SCOPE4); String tr3_success = (String) portletReq.getPortletSession().getAttribute(Constants.RESULT_ATTR_PREFIX + "AddlEnvironmentTests_SPEC2_18_Sessions_tr3", PORTLET_SCOPE); if (tr3_success == null) { tr3.setTcSuccess(true); } else { tr3.appendTcDetail("Failed becuase AddlEnvironmentTests_SPEC2_18_Sessions_tr3 is found " + "even though it was saved by another portlet in PORTLET_SCOPE"); } tr3.writeTo(writer); /* TestCase: V2AddlEnvironmentTests_SPEC2_18_Sessions_httpSession5 */ /* Details: "If the PortletSession object is invalidated by a */ /* portlet, the portlet container must invalidate the associated */ /* HttpSession object" */ PortletRequestDispatcher rd = portletConfig.getPortletContext().getNamedDispatcher("AddlEnvironmentTests_SPEC2_18_Sessions_invalidate2"); rd.include(portletReq, portletResp); }
Example 9
Source File: PortletTests_Portlet_ApiRender.java From portals-pluto with Apache License 2.0 | 4 votes |
@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(); JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails(); // Create result objects for the tests /* TestCase: V2PortletTests_Portlet_ApiRender_init1 */ /* Details: "Method init(PortletConfig): is called for the portlet */ /* defined in the deployment descriptor" */ TestResult tr0 = tcd.getTestResultFailed(V2PORTLETTESTS_PORTLET_APIRENDER_INIT1); String name=portletConfig.getPortletName(); try { if(name.equals(this.getClass().getSimpleName()) && initCalled==true) tr0.setTcSuccess(true); } catch(Exception e) {tr0.appendTcDetail(e.toString());} tr0.writeTo(writer); /* TestCase: V2PortletTests_Portlet_ApiRender_render1 */ /* Details: "Method render(RenderRequest, RenderResponse): is called */ /* when the portlet is to be rendered" */ TestResult tr1 = tcd.getTestResultFailed(V2PORTLETTESTS_PORTLET_APIRENDER_RENDER1); tr1.setTcSuccess(true); tr1.writeTo(writer); /* TestCase: V2PortletTests_Portlet_ApiRender_render2 */ /* Details: "Method render(RenderRequest, RenderResponse): is called */ /* when a Render URL for the portlet is triggered" */ TestResult tr2 = tcd.getTestResultFailed(V2PORTLETTESTS_PORTLET_APIRENDER_RENDER2); { PortletURL rurl = portletResp.createRenderURL(); rurl.setPortletMode(PortletMode.VIEW); tr2.setTcSuccess(true); tr2.writeTo(writer); } }
Example 10
Source File: AddlRequestTests_SPEC2_11_Render_parameter11.java From portals-pluto with Apache License 2.0 | 4 votes |
@Override public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException { JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails(); long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); PrintWriter writer = portletResp.getWriter(); /* TestCase: V2AddlRequestTests_SPEC2_11_Render_parameters11 */ /* Details: "If a portlet receives a render request that is the */ /* result of a client request targeted to another portlet in the */ /* portal page, the parameters should be the same parameters as of */ /* the previous render request from this client" */ if (portletReq.getParameter("tr1") == null) { PortletURL rurl = portletResp.createRenderURL(); rurl.setParameters(portletReq.getPrivateParameterMap()); rurl.setParameter("tr1", "true"); TestSetupLink tb = new TestSetupLink(V2ADDLREQUESTTESTS_SPEC2_11_RENDER_PARAMETERS11, rurl); tb.writeTo(writer); } else { TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_RENDER_PARAMETERS11); if (portletReq.getParameter("tr1_ready") != null && portletReq.getParameter("tr1_ready").equals("true")) { /* TestCase: V2AddlRequestTests_SPEC2_11_Render_parameters11 */ /* Details: "If a portlet receives a render request that is the */ /* result of a client request targeted to another portlet in the */ /* portal page, the parameters should be the same parameters as of */ /* the previous render request from this client" */ if (portletReq.getParameter("tr1") != null && portletReq.getParameter("tr1").equals("true")) { tr1.setTcSuccess(true); } else { tr1.appendTcDetail( "Test case failed as render parameter of this client didn't remain same after recieving render request from another portlet"); } } else { tr1.appendTcDetail( "Test case failed as public parameter tr1_ready is not set by V2AddlRequestTests_SPEC2_11_Render portlet"); } tr1.writeTo(writer); } }