留言板

Dynamic Portlet Creation - Good Practice?

Adarsh Ramamurthy,修改在12 年前。

Dynamic Portlet Creation - Good Practice?

New Member 帖子: 7 加入日期: 11-11-21 最近的帖子

Is it a good practice to have one portlet A creating multiple instances of another portlet B and adding them to the page? I understand there would be permission and performance implications but want to know what the community recommends.

A typical scenario would be portlet A causing a list of search results to be retrieved. Now, we have two options for displaying the results.

1. Have a single static results portlet B which displays all the results inline.
2. Make B represent one result item and have an instance of B created and added on to the page for each query done from A.

If it is purely for cosmetic reasons, I would always recommend using approach 1 and making the individual result items look like portlets with borders added.

Any inputs appreciated.

thumbnail
David H Nebinger,修改在12 年前。

RE: Dynamic Portlet Creation - Good Practice? (答复)

Liferay Legend 帖子: 14914 加入日期: 06-9-2 最近的帖子
As a matter of usability, the second option would be a nightmare...

Multiple copies of portlet B on a page makes each one operate independently of each other, each having their own portlet lifecycle and each could be in a different mode (i.e. one editing while one viewing)... Also you'd have to figure out how to clear all of the instances of portlet B when a search begins and create new one(s) w/ the new search results.

Add to this the issue that portlets are typically visible to all users (unless during your creation process you get the permissions set correctly). So if you do a search that creates 10 copies of portlet B and I navigate to the page, I'm going to see 10 bogus copies of B but will do my own search which potentially whacks your copies of portlet B...

What a nightmare. I wouldn't even suggest pursuing this at all.

Using a single portlet B which has the list will work a lot better. Drilling into a list item (i.e. to a detail page) means you only have to worry about editing a single entity at a time. It will be much easier to code, test, and maintain.

We solve these things using portlet IPC, where portlet A notifies portlet B when a new list needs to be displayed and portlet B can manage the various list activities.
thumbnail
Nagendra Kumar Busam,修改在12 年前。

RE: Dynamic Portlet Creation - Good Practice?

Liferay Master 帖子: 678 加入日期: 09-7-7 最近的帖子
I totally agree with David, suppose think a scenario if 100 different criteria user searches are you going to create 100 portlet B's
Adarsh Ramamurthy,修改在12 年前。

RE: Dynamic Portlet Creation - Good Practice?

New Member 帖子: 7 加入日期: 11-11-21 最近的帖子

Thanks a lot guys. We decided not to go with approach 2. I was never in favour of it too.