Java Code Examples for javax.portlet.RenderRequest#removeAttribute()
The following examples show how to use
javax.portlet.RenderRequest#removeAttribute() .
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: ComplexPortletApplicationContext.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void postHandleRender( RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView) throws PortletException { if (request.getAttribute("test2-remove-post") != null) { throw new PortletException("Wrong interceptor order"); } if (!"test1-remove-post".equals(request.getAttribute("test1-remove-post"))) { throw new PortletException("Incorrect request attribute"); } request.removeAttribute("test1-remove-post"); }
Example 2
Source File: ComplexPortletApplicationContext.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void afterRenderCompletion( RenderRequest request, RenderResponse response, Object handler, Exception ex) throws PortletException { if (request.getAttribute("test2-remove-after") != null) { throw new PortletException("Wrong interceptor order"); } request.removeAttribute("test1-remove-after"); }
Example 3
Source File: ComplexPortletApplicationContext.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void postHandleRender( RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView) throws PortletException { if ("true".equals(request.getParameter("noView"))) { modelAndView.clear(); } if (request.getAttribute("test1-remove-post") == null) { throw new PortletException("Wrong interceptor order"); } if (!"test2-remove-post".equals(request.getAttribute("test2-remove-post"))) { throw new PortletException("Incorrect request attribute"); } request.removeAttribute("test2-remove-post"); }
Example 4
Source File: ComplexPortletApplicationContext.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void afterRenderCompletion( RenderRequest request, RenderResponse response, Object handler, Exception ex) throws Exception { if (request.getAttribute("test1-remove-after") == null) { throw new PortletException("Wrong interceptor order"); } request.removeAttribute("test2-remove-after"); }
Example 5
Source File: HeaderPortletTests_SPEC15_MimeResponse_ApiHeader1.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_MimeResponse_ApiHeader1"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_MimeResponse_ApiHeader1"); }
Example 6
Source File: HeaderPortletTests_SPEC15_MimeResponse_ApiHeader2.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_MimeResponse_ApiHeader2"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_MimeResponse_ApiHeader2"); }
Example 7
Source File: HeaderPortletTests_SPEC14_HeaderAttr.java From portals-pluto with Apache License 2.0 | 5 votes |
@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_HeaderAttr"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC14_HeaderAttr"); }
Example 8
Source File: HeaderPortletTests_SPEC3_6_4_HeaderPortlet.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); ModuleTestCaseDetails tcd = new ModuleTestCaseDetails(); /* TestCase: V3HeaderPortletTests_SPEC3_6_4_HeaderPortlet_renderHeaders */ /* * Details: "renderHeaders() method is called before render() method if * the portlet implements HeaderPortlet interface." */ { TestResult result = tcd.getTestResultFailed( V3HEADERPORTLETTESTS_SPEC3_6_4_HEADERPORTLET_RENDERHEADERS); result.setTcSuccess(tr0_success); result.writeTo(writer); tr0_success = false; } String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC3_6_4_HeaderPortlet"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC3_6_4_HeaderPortlet"); }
Example 9
Source File: HeaderPortletTests_SPEC15_HeaderResponse2.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_HeaderResponse2"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_HeaderResponse2"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_getPortletOutputStream */ /* Details: "Data written to the HeaderResponse writer is added to the */ /* aggregated portal document HEAD section." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var outputStreamTag = document.getElementsByClassName('output-stream-tag');"); writer.write(" if(outputStreamTag.length){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_getPortletOutputStream-result').innerHTML = 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency */ /* Details: "Method addDependency(String name, String scope, String version) */ /* - Adds a dependency on a page-level resource that is managed by the */ /* portal." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" if (typeof window.portlet != 'undefined') { "); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency-result').innerHTML = 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); }
Example 10
Source File: HeaderPortletTests_SPEC14_HeaderReq.java From portals-pluto with Apache License 2.0 | 5 votes |
@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 11
Source File: HeaderPortletTests_SPEC14_RenderState_ApiHeader.java From portals-pluto with Apache License 2.0 | 5 votes |
@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_RenderState_ApiHeader"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC14_RenderState_ApiHeader"); }
Example 12
Source File: HeaderPortletTests_SPEC14_PortletRequest_ApiHeader2.java From portals-pluto with Apache License 2.0 | 5 votes |
@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_PortletRequest_ApiHeader2"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC14_PortletRequest_ApiHeader2"); }
Example 13
Source File: HeaderPortletTests_SPEC15_PortletResponse_ApiHeader.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_PortletResponse_ApiHeader"); writer.write("<p>" + msg + "</p>"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_PortletResponse_ApiHeader"); /* TestCase: V3HeaderPortletTests_SPEC15_PortletResponse_ApiHeader_addPropertyB1 */ /* Details: "Method addProperty(String, org.w3c.dom.Element): Adds an XML DOM */ /* Element to the response for the specified key" */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var scriptTag = document.getElementsByClassName('testProperty1');"); writer.write(" if(scriptTag.length){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_PortletResponse_ApiHeader_addPropertyB1-result').innerHTML = 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); /* TestCase: V3HeaderPortletTests_SPEC15_PortletResponse_ApiHeader_addPropertyB2 */ /* Details: "Method addProperty(String, org.w3c.dom.Element): If a DOM */ /* Element for the specified key already exists, the new element is added in */ /* addition to the existing element" */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var scriptTag = document.getElementsByClassName('testProperty2');"); writer.write(" if(scriptTag.length){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_PortletResponse_ApiHeader_addPropertyB2-result').innerHTML = 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); }
Example 14
Source File: HeaderPortletTests_SPEC7_14_RenderRequest.java From portals-pluto with Apache License 2.0 | 5 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC7_14_RenderRequest"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC7_14_RenderRequest"); }
Example 15
Source File: HeaderPortletTests_SPEC15_HeaderResponse1.java From portals-pluto with Apache License 2.0 | 4 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { PrintWriter writer = renderResponse.getWriter(); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_HeaderResponse1"); writer.write("<p>" + msg + "</p>\n"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_HeaderResponse1"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_getWriter */ /* Details: "Data written to the HeaderResponse writer is added to the */ /* aggregated portal document HEAD section." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var jQueryTag = document.getElementsByClassName('jquery-tag');"); writer.write(" if(jQueryTag.length){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_getWriter-result').innerHTML = 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency7 */ /* Details: "Method addDependency(String name, String scope, String version, */ /* String markup) - Adds a dependency on a page-level resource that is */ /* managed by the portal and adds a resource for addition to the page for the */ /* dependency." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var dependencyTag = document.getElementsByClassName('dependency-test');"); writer.write(" if(dependencyTag.length){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency7-result').innerHTML= 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency8 */ /* Details: "Method addDependency(String name, String scope, String version, */ /* String markup) - The portal may choose to include the later version of the */ /* resource on the page if 2 same dependencies with different version are */ /* declared." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" var dependencyTag2_1 = document.getElementsByClassName('dependency-test2-1');"); writer.write(" var dependencyTag2_2 = document.getElementsByClassName('dependency-test2-2');"); writer.write(" if(dependencyTag2_1.length==0 && dependencyTag2_2.length>0){"); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency8-result').innerHTML= 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); /* TestCase: V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency2 */ /* Details: "Method addDependency(String name, String scope, String version) */ /* - The dependency added by this method can be shared with other portlets." */ writer.write("<script type='text/javascript'>"); writer.write("document.addEventListener('DOMContentLoaded', function(event) {"); writer.write(" if (typeof window.portlet != 'undefined') { "); writer.write(" document.getElementById('V3HeaderPortletTests_SPEC15_HeaderResponse_addDependency2-result').innerHTML= 'Test Succeeded';"); writer.write(" }"); writer.write("});"); writer.write("</script>"); }
Example 16
Source File: HeaderPortletTests_SPEC15_Header.java From portals-pluto with Apache License 2.0 | 4 votes |
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { ModuleTestCaseDetails tcd = new ModuleTestCaseDetails(); PrintWriter writer = renderResponse.getWriter(); /* TestCase: V3HeaderPortletTests_SPEC15_Header_cookie8 */ /* * Details: "Cookies set during the Header phase should be available to * the portlet during the Resource phase" */ writer.write( "<div id=\"V3HeaderPortletTests_SPEC15_Header\">no resource output.</div>\n"); ResourceURL resurl = renderResponse.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(\"V3HeaderPortletTests_SPEC15_Header\").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"); /* TestCase: V3HeaderPortletTests_SPEC15_Header_cookie10 */ /* * Details: "Cookies set during the Header phase should be available to * the portlet during a subsequent Render phase" */ Cookie[] cookies = renderRequest.getCookies(); StringBuilder txt = new StringBuilder(128); txt.append("<p>Debug info:"); txt.append("<br>"); txt.append("# Cookies: ").append(cookies.length).append("<br>"); TestResult tr2 = tcd .getTestResultFailed(V3HEADERPORTLETTESTS_SPEC15_HEADER_COOKIE10); for (Cookie c : cookies) { txt.append("Name: ").append(c.getName()); txt.append(", Value: ").append(c.getValue()).append("<br>"); if (c.getName().equals("header_tr2_cookie") && c.getValue().equals("true")) { txt.append("<br>").append("Found my cookie!").append("<br>"); c.setMaxAge(0); c.setValue(""); tr2.setTcSuccess(true); } } tr2.writeTo(writer); txt.append("</p>"); writer.append(txt.toString()); String msg = (String) renderRequest.getAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_Header"); writer.write("<p>" + msg + "</p>"); renderRequest.removeAttribute( RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC15_Header"); }