Embeded portlet constructor or pageLoad is not called in web content

Bilal Hussain, modified 6 Years ago. New Member Posts: 14 Join Date: 3/22/17 Recent Posts
Hi folks,

I've created the jsf portlet and embeded it into web content. But issue is consctructor of portlet is not called while i embed this portlet in theme then constructor  get called.
This same issue occurs for the Jsp porltel mvc

Additionally ,as ususally  when  i drag and drop the portlet on page and refresh it works smoothly and constructor method get called.
I've put my controller class bean scope is request in facing-config.xml for jsf.

I've been following this link and using this tag <@liferay_portlet["runtime"] for embeding portlet.

Any body have idea about this how to resolve this issue in LR 7.1
Please help.

Thanks in advance.
​​​​​​​
Bilal
thumbnail
Olaf Kock, modified 6 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Bilal Hussain

I've created the jsf portlet and embeded it into web content. But issue is consctructor of portlet is not called while i embed this portlet in theme then constructor  get called.
This same issue occurs for the Jsp porltel mvc
Just like with Servlets, there's typically only one Portlet Object only in the whole system. The portlet is not supposed to have any internal state: The state is passed through the Request and Response object. What you describe is working as it's designed.

Think of it: Would you expect one object per page? Or one object per page and user? Or just one object per user, whatever page it might be on? Would you expect all portlets of a site to be instantiated or just the current page? Would you expect them to stay around in memory until the session runs out, or just until the request is handled successfully?

While you might have an answer for your expectation, everybody would have a different answer. And commonly, there's only one object ever, because they're not supposed to keep any state anyways. AFAIK the spec doesn't specify it at all, but more objects don't make any sense for any implementation.
thumbnail
Neil Griffin, modified 6 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Section 5.2 of the Portlet 3.0 Specification titled "Relationship to the Portlet Context" states:

The portlet container must enforce a one-to-one correspondence between a portlet application and its portlet context. If the application is a distributed application, the portlet container must create a single PortletContext instance per VM. A PortletContext object provides a portlet with information about the application. 

Other sections in the spec reinforce the singleton nature of a portlet as well. For example, Section 4.8.1 titled "Initialization and Destruction" states:
The portlet container calls the annotated method to initialize the portlet when it is being placed into service. 
Bilal Hussain, modified 6 Years ago. New Member Posts: 14 Join Date: 3/22/17 Recent Posts
Thanks Olaf and Neil for you reply.

Issue has been resolved. Actually while creating template of web content  I've checked the "chacheable" checkbox. This is not allowing to update or modify the embeded portlet in web content.

Just I've unchecked the "chacheable" checkbox in template  and issue get resolved.