Foren

Liferay portlet in einem anderen portlet zeigen

Şengül Mor, geändert vor 8 Jahren.

Liferay portlet in einem anderen portlet zeigen

New Member Beiträge: 18 Beitrittsdatum: 16.09.15 Neueste Beiträge
Hallo,
ich beschaftige mich gerade intensiv mit Liferay. Ich benutze liferay-portal-6.2-ce-ga4 (bundle tomcat) und als IDE benutze ich Liferay IDE(eclipse). Ich habe folgendes problem. Ich habe in Liferay Eclipse, drei Liferay Plugin Portlet erstellt.
Sie heißen
1. voda
2. customer(hat mehrere portlets)
3. subscriber(hat mehrere portlets)
Ich möchte dass portlet voda, ein portlet vom customer und ein portlet vom subscriber beinhaltet, anzeigt.
D.h. in view.jsp von voda habe ich ein button erstellt, wenn ich auf den button klicke, geht es weiter zu show.jsp im voda. So, genau hier im show.jsp sollte das portlet von customer und das portlet vom sucbscriber zu sehen sein.

Wie kann ich das machen? Gibt es irgendein Link den ich im show.jsp angeben kann? Ein beispiel dafür wäre gut? Hoffentlich habe ich es verständlich erklärt.
Vielen dank
thumbnail
Olaf Kock, geändert vor 8 Jahren.

RE: Liferay portlet in einem anderen portlet zeigen

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
Als Beispiel dafür fällt mir das NestedPortlet ein - ein Portlet, das selbst mehrere Portlets anzeigt. Ich mag es nicht besonders, weil ich lieber neue Layout Templates erstellen würde als mit diesem Portlet rumzumachen, aber als Technologiedemo taugt es.
Tobias Hahn, geändert vor 8 Jahren.

RE: Liferay portlet in einem anderen portlet zeigen

New Member Beitrag: 1 Beitrittsdatum: 05.08.14 Neueste Beiträge
Hallo Şengül Mor,

ich habe ein ähnliches Problem mal gelöst.
Meine Anforderung war dabei ebenfalls, dass ein Portlet bei Bedarf den Inhalt eines anderen Portlets anzeigt.
Ich habe dafür über die PortletUtils die URL zu dem jeweiligen Portlet generiert und aufgerufen. Dabei nutzte ich eine RenderUrl.

Zugegebener Maßen ist der Code nicht unbedingt sauber. Gerade die Menge der funktionalen Parameter der Methoden gehören veringert, indem man sie in einer Klasse zusammen fasst. emoticon

Das sieht dabei folgendermaßen aus:

Finden der PortletId:

/**
* Gets the portlet id.<br>
* Uses the Current CompanyId and the portletName which is the same as can
* be found insde portlet.xml but without the '-' Delimiter.
*
* @param portletName
* the portlet name
* @param companyId
* the company id
* @return the portlet id
* @throws EvamPortletUtilException
* the evam portlet uitil exception if it is not Found or a
* critival SystemException occurs
*/
public static String getPortletId(String portletName, long companyId)
throws EvamPortletUtilException {
List<Portlet> portletList = getPortletList(companyId);
String portletId = findPortletId(portletList, portletName);
return portletId;
}

/**
* Find portlet id.<br>
* iterates through the list to get the PortletId to look, whether the name
* is in there. It automatically adds the portletNameDelimiter to verify,
* that the real PortletId is returned.
*
* @param portletList
* the portlet list
* @param portletName
* the portlet name
* @return the string
* @throws EvamPortletUtilException
* the evam portlet uitil exception
*/
static String findPortletId(List<Portlet> portletList, String portletName)
throws EvamPortletUtilException {

for (Portlet portlet : portletList) {

String portletId = portlet.getPortletId();
String delimitedProtletName = portletName.toLowerCase()
+ PORTLET_NAME_DELIMITER;
if (portletId.toLowerCase().contains(
delimitedProtletName.toLowerCase())) {
return portletId;
}
}
throw new EvamPortletUtilException(
"PortletId was not Found. Either it is not installed or the name is wrong. PortletName: "
+ portletName);

}

/**
* Gets the portlet list.<br>
* PackageProtected for test-causes.
*
* @param companyId
* the company id
* @return the portlet list
* @throws EvamPortletUtilException
* the evam portlet uitil exception
*/
private static List<Portlet> getPortletList(long companyId)
throws EvamPortletUtilException {
List<Portlet> portletList = new LinkedList<Portlet>();
try {
portletList.addAll(PortletLocalServiceUtil.getPortlets(companyId));
} catch (SystemException e) {
logger.error("Critical Exception on getting PortletList with CompanyId "
+ companyId);
throw new EvamPortletUtilException(
"Critical Exception on getting PortletList with CompanyId",
e);
}
return portletList;
}

Erstellen der URL Mithilfer der PortletId
/**
* Creates the Url that redirects to the ExhibitorProfile Url </br> First of
* all it fetches the portletName dynamically. Then it passes through the @parameter
* . All of them are just set.
*
* @param request
* the request
* @param themeDisplay
* theme display
* @param adminToken
* the admin token
* @param userGroup
* the user group
* @param event
* the event
* @param redirect
* the redirect
*
* @return the string
*
* @throws PortletModeException
* the portlet mode exception
* @throws IOException
* the IO exception
* @throws EvamPortletUtilException
* the evam portlet uitil exception
* @throws WindowStateException
* the window state exception
*/
public static String createExhibitorProfilePortletUrl(
PortletRequest request, ThemeDisplay themeDisplay,
String adminToken, EvamUserGroupEntity userGroup,
EvamEventEntity event, String redirect, long companyId)
throws PortletModeException, IOException, EvamPortletUtilException,
WindowStateException {

String portletId = MyClass.getPortletId(
PORTLET_NAME, companyId);

long plid = themeDisplay.getPlid(); // 10178

String url = createUrl(request, portletId, plid, adminToken, userGroup,
event, redirect);

return url;
}
Aufruf innerhalb der JSP-File
String attributeUrl = myClass.createExhibitorProfilePortletUrl(renderRequest, themeDisplay, token, currentEntry.getUserGroupEntity(), currentEntry.getEvamEventEntity(), redirect, themeDisplay.getCompanyId());

Ich hoffe ich konnte helfen.

Viele Grüße