Open IT Experts for Enterprise

Zylk empresa de desarrollo de ecommerce

How to link portlets located on different pages in Liferay Portal

Gustavo Fernández
Gustavo Fernández

Following
with the IPC (inter portlet communication)
, let’s go with an
example that explains how to create a link in one portlet that points
to another portlet located on a different page (editor’s note: wow!! –
editor’s hint: portlets are not pages)

To do this we have to use the tlds :


liferay-portlet:renderURL
liferay-portlet:actionURL

and the concepts of


plid: referenced page layout id
portletName: referenced
portlet name


The renderURL and the actionURL are tags provided by Liferay
that extend the standard tlds. Note: this kind of communication is not
part of the standard of the portlets JSR168 and JSR286.

  • The plid is the id of the page where we deploy one portlet, we can
    use LayOutLocalService to seek the id, or query it in the database directly.
  • The portletName is the identifier of the portlet and is part of
    the deployment descriptor of the portlet. This id is composed by
    portletId+_WAR_+thenameofwarthatencapsulatestheportlet and
    optionally the _INSTANCE_ if the portlet is instanciable.

 

If we have one portlet, and we use this tld into the jsp:

<liferay-portlet:renderURL plid="13605"
portletName="mynews_WAR_myresourcesportlet" var="prueba"></liferay-portlet:renderURL>

and this portlet creates a link to other portlet, in this case,
mynews_WAR_myresourcesportlet located in the page with plid 13605.
This link is a render link.

The next sample shows how to create an actionURL:

<liferay-portlet:actionURL name="newMyNew"
plid="13605"
portletName="mynews_WAR_myresourcesportlet" var="prueba2"></liferay-portlet:actionURL>

We can also pass parameters:

<liferay-portlet:renderURL plid="13605"
portletName="mynews_WAR_myresourcesportlet" var="prueba">

  <liferay-portlet:param name="resourcePrimKey"
value="123456" />

</liferay-portlet:renderURL>

If the plid is not used, the portal assumes that the portlets are
located into the same page.

Si te ha parecido interesante comparte este post en RRS

Facebook
LinkedIn
Telegram
Email

Leer más sobre temas relacionados

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *