0

I have a liferay page where it should have a freeform layout, but the number of portlets is not know before run time. How can i add protlets dynamically and sepcify their location in the page?

Thank you.

Marwan Tushyeh
  • 1,505
  • 4
  • 24
  • 47

1 Answers1

0

Yes you can add portlets to a page dynamically.

In liferay page is known as Layout and you add portlets to a Layout.

The code in this answer (refer the addPortlet method) will help you add a portlet to a page when you know the layout i.e. you know the page to which the portlets need to be added.

Also you need to specify the column to which the portlet would be added on the page.

You mentioned:

but i don't want to add a portlet from another portlet, i want to add all portlets to a page at run time.

The piece of code would remain the same irrespective of the fact that you want to add portlets through a portlet or through a action class like when the User logins you call the code to add portlets inside of the LoginPostAction or through when some other action is performed.

Community
  • 1
  • 1
Prakash K
  • 11,669
  • 6
  • 51
  • 109