Saiyine
Saiyine

Reputation: 1585

Accessing an action from a portlet from another

So I have an action in a portlet "pA" that prints some info based on the logged user, and now I need that info in another portlet "pB". Instead of duplicating the code, I want to access the action of porlet "pA" from "pB". Is that even possible?

Researching I've managed to get to this at the beginning of "pB":

<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>

<liferay-portlet:actionURL var="name" portletName="pA_WAR_war-of-pA">
    <liferay-portlet:param name="view" value="v" />
</liferay-portlet:actionURL>

<h1>URL:: <a href="${name}">${name}</a></h1>

But it generates an url for "pB" instead of "pA" ???

Upvotes: 0

Views: 43

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48057

I wouldn't worry so much if this is possible, because it's bad style. If you need the same code in two different portlets, just provide it in a library and use that from both portlets.

A portlet, on the UI layer, should be a closed concept and not have interdependencies with other portlets. A dependency on a common library however is fine.

Upvotes: 3

Related Questions