1
votes

Hope you are doing fine.

This is my scenario. I have multiple (20+) Liferay portlets that use grids/tables to display data.

Each portlet retrieves data based on a different criteria.

However, the grid is the same with some common functionalities such as filtering, pagination, data export etc.

Currently, each time we have to make a change in the grid style, I have to make the change in each of the 20+ portlets. This is really inefficient and results in a lot of time wasted.

Hence, I was wondering whether it is possible to create a generic 'portlet' or 'composite' so that it can display data from multiple portlets? To elaborate, the generic portlet/composite will contain the grid, filtering, pagination, export etc. features.

This generic portlet/composite will receive data from the various portlets and simply display it.

Hence, if I need to make any change in the grid style, making the change in only one place will suffice.

Has any one experienced such a scenario before?

Do you have any solution?

Thanks in advance for any help.

2

2 Answers

1
votes

If you need only retrieve data by different criteria, have functionality like export data,print,pagination etc, you don't need 20+ different portlets you may use one portlet and have 20+ it instances, each would be configured like enable.export, enable.print, data.criteria and so on. Inside portlet your logic would build grid and data what you need.

If you really need Generic Portlet you may try to have all your 20+portlets in one .war. You'd simply include jsp's that are common within some portlets, extend controllers etc.

Even more... If you need to send data between portlets you may create javascript controllers that will send events each other, through Ajax get data and fill in your jsps(in that case you may use some templates). Please ask if something is unclear.

0
votes

The best solution would be to use one portlet for retrieving all data, and generalise the data retrieving with one interface and different implementations - not with different port lets.

You can though try to use Liferay's Interportlet Communication facility to provide data from source portlets to target portlet - http://www.liferay.com/community/wiki/-/wiki/Main/Inter-portlet+communication

But it has it's own caveats - you'd either have to submit data in browser using AJAX or JS events, or have to use JSR-286 (Portlets 2.0) events that work on server-side, but require one to trigger an action in order to make events occur (i.e. open portlet with action URL and not render URL). More on it here - http://www.liferay.com/community/wiki/-/wiki/Main/Portlet+to+Portlet+Communication