1 Reply Latest reply on Jun 30, 2009 1:28 AM by dorothy

    Portlet Cacheability Levels

      Hi

      Hi

      I was testing the cacheability levels that are introducced in JSR 286 on JBoss 4.3 EAP. Below is the code:

      protected void doView(RenderRequest request, RenderResponse response)
       throws PortletException, IOException, UnavailableException {
       PrintWriter pw = response.getWriter();
       ResourceURL rurl = response.createResourceURL();
      
       rurl.setCacheability("PORTLET");
       rurl.setParameter("name", "abc");
       pw.println("<BR><A HREF=\"" + rurl.toString() + "\">Serve Resource</A><BR>");
       pw.close();
       }
      
       public void serveResource(ResourceRequest request, ResourceResponse response)
       throws PortletException, IOException {
       PrintWriter pw = response.getWriter();
       pw.println("<BR>Inside Serve Resource<BR>");
       pw.println("<BR>Param Value = " + request.getParameter("name"));
       pw.println("<BR>Cacheability = " + request.getCacheability());
       pw.println("<BR>PortletMode = " + request.getPortletMode());
       pw.println("<BR>Window State = " + request.getWindowState());
       pw.close();
       }


      JBoss automatically resets the cacheability to default i.e. 'PAGE'. No matter if I set 'FULL' or 'PORLET' it just does not take effect. Is this some kind of a bug or am I missing anything?

      Thanks

        • 1. Re: Portlet Cacheability Levels

          Sorry about a small change in the code. My code is as below:

          protected void doView(RenderRequest request, RenderResponse response)
           throws PortletException, IOException, UnavailableException {
           PrintWriter pw = response.getWriter();
           ResourceURL rurl = response.createResourceURL();
          
           rurl.setCacheability(ResourceURL.FULL);
           rurl.setParameter("name", "abc");
           pw.println("<BR><A HREF=\"" + rurl.toString() + "\">Serve Resource</A><BR>");
           pw.close();
           }
          
           @Override
           public void serveResource(ResourceRequest request, ResourceResponse response)
           throws PortletException, IOException {
           PrintWriter pw = response.getWriter();
           pw.println("<BR>Inside Serve Resource<BR>");
           pw.println("<BR>Param Value = " + request.getParameter("name"));
           pw.println("<BR>Cacheability = " + request.getCacheability());
           pw.println("<BR>PortletMode = " + request.getPortletMode());
           pw.println("<BR>Window State = " + request.getWindowState());
           pw.close();
           }


          And this actually throws a runtime exception