How to open a portal page in dialog box

In the Opening a popup inside portlet, i built a sample portlet that will open www.google.com in a popup dialog box, but most probably you will want to open another portal page in dialog box.

You can do that by creating a URL mapping to the portal page that you want to open in popup dialog box. In my local environment i have a portal page at /wpcert/mydemo/jmeter1 URL, that i wanted to open in popup dialog box, so i changed my JSP like this


<%@page language="java" contentType="text/html; %>
<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/portal.tld" prefix="portal" %>

<portlet:defineObjects />
<h3>Popup portlet</h3>

<script type="text/javascript">
<!--
function openPopup(popupUrl){
if (window.showModalDialog) {
window.showModalDialog(popupUrl,"name","dialogWidth:255px;dialogHeight:250px");
} else {
window.open(popupUrl,'name',
'height=500,width=500,toolbar=no,directories=no,status=no,menubar=no,
scrollbars=no,resizable=no ,modal=yes');
}
}
//-->
</script>



<input type="button" onclick="openPopup('/wpcert/mydemo/jmeter1')"
label="Open popup" value="Open Popup" />


And now this is how my portal page popup dialog box looks like




If you dont want to create all the URL mappings upfront then you can also use Portal URL generation service for creating URL to the portal page, i might blog about sample portlet :)

4 comments:

Abhi said...

Thanks for info....
SEO Company in Bangalore

Abhi said...

Thanks for info....
SEO Company in Bangalore

Abhi said...



Thanks for info
SEO Company in Bangalore

IDesignPassion said...

Thank you for sharing article with us. It is reaaly awesome. Keep posting such information.
Custom website design Phoenix