Suppose portlet X is deployed in Liferay and has a friendly URL. Suppose a user logs into the Liferay Portal through a mapped URL, but the portlet is not in the portal — it is deployed but not added to the page.
My problem is that when the user uses the associated URL, nothing happens - the portal does not give visual feedback that the target portlet is missing.
How can i change this? I need some warning / notification to user ...
- change -
I do not need to use a second portlet to check for another portlet.
Regards,
AFAIK, . . , .
, :
ThemeDisplay JSP <liferay-theme:defineObjects />, ThemeDisplay JSP.
ThemeDisplay
<liferay-theme:defineObjects />
String typeSettings = themeDisplay.getLayout().getTypeSettings();
:
layout-template-id=foobar_2column sitemap-include=1 column-1=foo_WAR_barportlet,abc_WAR_barportlet,56_INSTANCE_K4Vv, column-2=baz_WAR_xyzportlet, sitemap-changefreq=daily
, foo WAR bar, foo_WAR_barportlet.
foo
bar
foo_WAR_barportlet
, , , .
<% if(!typeSettings.contains("foo_WAR_barportlet")) { %> <h3 style="color: red">Alert! Portlet foo_WAR_barportlet not installed.</h3> <% } %>
, Velocity Java. , .
portal_normal.vm
#if(!$layout.getTypeSettings().contains("foo_WAR_barportlet")) <h3 style="color: red">Alert! Portlet foo_WAR_barportlet not installed.</h3> #end
, , Inter-portlet communication, , . ( ListenerPortlet), .
Listener , .
, , javascript- Listener , .
Liferay.trigger(eventName, data)
Listener
Liferay.bind(eventName, function, [scope]) //make the scope as page
, , . , .
IPC
, ,
It would be better if we try this,
ThemeDisplay themeDisplay = request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = LayoutLocalServiceUtil.getLayout(themeDisplay.getLayout().getPlid()); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet)layout.getLayoutType(); List allPortletIds = layoutTypePortlet.getPortletIds();
If the list is empty, the page does not contain any portlets.
Gettings LayoutTypePortletensures that the page the user has been redirected to is a layout type portlet.
LayoutTypePortlet