Fórum

Links in custom POP_UP inside ControlPanel not working

Oliver Bayer, modificado 9 Anos atrás.

Links in custom POP_UP inside ControlPanel not working

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hi there,

I'm using Liferay v6.2 and I'm having a little -hopefully simple emoticon- AUI question.

Inside the control panel I manage to open a popup with a custom struts_action by using a liferay-ui:icon. In this popup some plain html links are generated. But if a user clicks on one of these links a new browser tab is opened (because of target="_blank") but the control panel is still shown instead of the link href.

Here are some code snippets for reference:
<%
PortletURL previewPageURL = renderResponse.createRenderURL();

previewPageURL.setParameter("struts_action", "/some/custom/struts/path");
previewPageURL.setParameter("groupId", String.valueOf(article.getGroupId()));
previewPageURL.setParameter("articleId", article.getArticleId());
previewPageURL.setWindowState(LiferayWindowState.POP_UP);
%>

<liferay-ui:icon image="preview" url="<%= &quot;javascript:&quot; + renderResponse.getNamespace() + &quot;previewPage();&quot; %>" message="Some message" />

<aui:script>
	function <portlet:namespace />previewPage()
	{
		window.open('&lt;%= previewPageURL %&gt;', '', 
			"directories=0,height=480,left=80,location=1,menubar=1,resizable=1,scrollbars=yes,status=0,toolbar=0,top=180,width=640");
	}
</aui:script>


Even if I put hard coded links like e.g.
<a href="/web/guest/home" target="_blank">Link to click</a>
inside the popup still the control panel page is opened in the new browser tab. And it's not because of the relative link, absolute links don't work either.

Any ideas, advices or maybe a better way to implement this?
Thanks in advance

Oli
thumbnail
Zsigmond Rab, modificado 9 Anos atrás.

RE: Links in custom POP_UP inside ControlPanel not working

Liferay Master Postagens: 728 Data de Entrada: 05/01/10 Postagens Recentes
Hi Oliver,

would you like to have a modal pop-up which shows only the content of a specific portlet like for example the configuration at the ootb portlets?

For that you should use the exclusive mode instead of pop-up.

If it's not your case, could you please elaborate a bit more?

Thank you,
Zsigmond
Oliver Bayer, modificado 9 Anos atrás.

RE: Links in custom POP_UP inside ControlPanel not working

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hi Zsigmond,

thanks for your feedback.

I was trying to extend the available actions from the webcontent section inside the control panel to show a new jsp in a popup like e.g. the preview action. Therefore I add a new struts action via a hook as described in this blog. The problem was that if I create plain simple html links in my popup it seems that you can't "break out" of the control panel. I've found a workaround/ solution at the my-pages dropdown and used a similar approach.

The popup:
<c:if test="<%= JournalArticlePermission.contains(permissionChecker, article, ActionKeys.UPDATE) %>">
	<liferay-portlet:renderurl plid="<%= JournalUtil.getPreviewPlid(article, themeDisplay) %>" var="previewArticleContentURLExt" windowstate="<%= LiferayWindowState.POP_UP.toString() %>">
		<portlet:param name="struts_action" value="/journal/preview_article_content_ext" />
		<portlet:param name="groupId" value="<%= String.valueOf(article.getGroupId()) %>" />
		<portlet:param name="articleId" value="<%= article.getArticleId() %>" />
	</liferay-portlet:renderurl>
	
	&lt;%
	String taglibOnClickExt = "Liferay.fire('previewArticle', {title: '" + HtmlUtil.escapeJS(article.getTitle(locale)) + "', uri: '" + HtmlUtil.escapeJS(previewArticleContentURLExt.toString()) + "'});";
	%&gt;
	
	<liferay-ui:icon image="preview" onClick="<%= taglibOnClickExt %>" url="javascript:;" message="Preview 2.0" />
</c:if>

The content of the popup (the jsp is called as a struts action):
PortletURL portletURL = new PortletURLImpl(request, PortletKeys.SITE_REDIRECTOR, plid, PortletRequest.ACTION_PHASE);

portletURL.setParameter("struts_action", "/my_sites/view");
portletURL.setPortletMode(PortletMode.VIEW);
portletURL.setWindowState(WindowState.NORMAL);
...
for loop
...
	portletURL.setParameter("groupId", String.valueOf(group.getGroupId()));
	portletURL.setParameter("privateLayout", String.valueOf(isPrivateLayout));
...
display the links:
<a href="<%= HtmlUtil.escape(portletURL.toString()) %>" onclick="Liferay.Util.forcePost(this); return false;" target="_blank">Link</a>

Not sure why you need this "logic" to create a simple link to a website inside the control panel, that's some Liferay magick emoticon.

This is part of my hook for providing a real webcontent preview feature as described here. This is the additional feature as described by Julien if someone is creating webcontents solely from the control panel to get a list with links to all websites/ pages the article is used on. This is work-in-progress but once I've finished it I will upload a new version of this hook.

If you have some free time you can maybe test this hook and give some feedback too emoticon.

Greetings Oli