I am developing a custom portlet (EDIT:I’m extending MVCPortlet), and looking at several examples and tutorials, I find that when the doView(RenderRequest, RenderResponse) method is overridden, at the end of it there is always at least this line:
super.doView(renderRequest, renderResponse);
or this:
include(viewJSP, renderRequest, renderResponse);
If I don’t put either of these my portlet doesn’t render anything, but any of them does the trick.
I would like to know which one I should be using, and why do I need to add them to get my portlet to work.
Thanks!
So you must be extending
MVCPortletclass. Both the calls are used to include the JSP after thedoViewprocessing is completed. If you look at the source code of this class then you would understand what the flow is, below is my explanation:This includes the default JSP i.e.
view.jsp, that you might (or not) have configured inportlet.xmlsomething like this:This super class method does nothing but calls the
include(viewJSP, renderRequest, renderResponse);method at the end.This method includes whatever JSP path you have specified for the parameter
viewJSP. So with this call you can specify including different JSP for different condition something like the following:So depending on your requirement you can use any to the two or the mix of the two as shown above. Hope this helps.