Why is the servlet request not available in the portlet API

The portlet APIs do not provide any reference to the surrounding servlet request and response objects. I know this is not the preferred user experience model, but it doesn't seem to be the case to remove all access.

I understand that for user interaction with portlets, you want to use the portlet URLs and let the portlet container handle the complexity.

However, if you have multiple portlets that mostly show variants of the same data, it makes sense for them to use the supplied data manipulation query.

We ended up using a custom Liferay call to get the request, and it all works as we wish.

However, I feel guilty.

So my question is, is there a root reason for the ban, or is it just to provide an understanding of the API environment for the authors?

+2


a source to share


1 answer


The portlet does not run directly into the Servlet container, but rather what is called the Portlet container.

You must have access to relevant information PortletRequest

, PortletResponse

and PortletContext

.



The reason is that two instances of the same portlet can run side by side on the same page, but still be isolated by their own life cycle . The portal will "mux", which is transparent to you, and it will transform from the servlet world to the portlet world. Portlet bridges are also available for developing portlets with non-portlet technologies (such as JSF). I agree that this is usually (very) difficult to use (due to the many frameworks and implementations available), but when you think about how it works conceptually, it's pretty nice .

The exact details will depend on the technologies you choose to develop the portlet. But I feel like there must be a way to do what you want using the portlet API.

+3


a source







All Articles