osingh
Dec 5th, 2007, 08:49 AM
Hello,
We have a portlet which generates a html fragment. We want to cache this fragment using OSCache. In order to do this we are trying to introduce our oscache caching logic on the html fragment generated by the doView method of the generic protlet.
Example code below
public class HelloWorldPortlet extends GenericPortlet {
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering HelloWorldPortlet.doView");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1>Hello World</h1>");
}
}
I am unable to get the html string from the RenderResponse object.
We have now written an interceptor to trap the doView method. Refering to the code below for the method afterRenderCompletion().
public class PortletNameInterceptor extends PortletApplicationObjectSupport
implements HandlerInterceptor, PortletContextAware {
private PortletContext portletContext;
public void setPortletConfig(PortletContext portletContext) {
this.portletContext = portletContext;
}
public void afterRenderCompletion(RenderRequest request, RenderResponse response, Object obj, Exception ex) throws Exception {
System.out.println("The doView method is completed");
}
}
Is there a way to get the html output in form of string from the RenderResponse response object inside afterRenderCompletion method.
Any suggestion, help will be appretiated.
Thanks Om
We have a portlet which generates a html fragment. We want to cache this fragment using OSCache. In order to do this we are trying to introduce our oscache caching logic on the html fragment generated by the doView method of the generic protlet.
Example code below
public class HelloWorldPortlet extends GenericPortlet {
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering HelloWorldPortlet.doView");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1>Hello World</h1>");
}
}
I am unable to get the html string from the RenderResponse object.
We have now written an interceptor to trap the doView method. Refering to the code below for the method afterRenderCompletion().
public class PortletNameInterceptor extends PortletApplicationObjectSupport
implements HandlerInterceptor, PortletContextAware {
private PortletContext portletContext;
public void setPortletConfig(PortletContext portletContext) {
this.portletContext = portletContext;
}
public void afterRenderCompletion(RenderRequest request, RenderResponse response, Object obj, Exception ex) throws Exception {
System.out.println("The doView method is completed");
}
}
Is there a way to get the html output in form of string from the RenderResponse response object inside afterRenderCompletion method.
Any suggestion, help will be appretiated.
Thanks Om