Before talking about the portlet request types and its flow cycle, lets first briefly talk about the portlets and portal. Portlets are the building blocks in the portal environment. Portal server provides the portlet container, the environment to run the portlets and also provides the capability to create the page by aggregating the multiple portlets together.
When a Portal page is requested, many portlets are usually invoked and the mark-up fragment from each portlet is combined within the Portal’s page mark-up. As portlet is not the complete page, it is just a fragment of the page. Flow of the request for the portlet is different from the servlet. Portlets have three different types of the request.
- Render Request
- Action Request
- Resource Request
Just for the explanation purpose consider a simple page with two portlets PortletA and PortletB dropped on it, as shown below.
Render Request is called for rendering of the page. Sequence diagram shown below shows the request flow for render request. When a render request goes to the portal server. Portal server calls the rendering logic of each portlet to get the HTML fragments and then combines all the HTML fragments to form the complete and returns the complete page HTML to browser.
Action Request is called for performing operation. for example database update, calling back end service. Sequence diagram shown below shows the request flow for action request. When a action request goes to the portal server. Portal server calls the action logic of the portlet to perform the back-end operation and then calls the render logic of all the portlets, as it do in the render request and returns the page to the browser.
Resource Request is called for fetching the specific resource. Sequence diagram shown below shows the request flow for resource request. When a resource request goes to the portal server, Portal server just calls executes the resource method of portlet for which request is coming and returns the response. In some scenarios, it is required to fetch the specific HTML fragment instead of the complete page. for example in case of AJAX calls, we want specific HTML/JSON data to be returned.