Opening a popup inside portlet

Opening a dialog box from portlet is one of the uncommon requirements, but i wanted to try that. Basic idea is opening a dialog box from portlet is normal as opening it from any other web application, but the problem is when you want to open a dialog box from any other web application.

I built this sample portlet which opens www.google.com in the dialog box like this


Inside the doView() method of the portlet i am forwarding control to index.jsp which is 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('www.google.com')"
label="Open popup" value="Open Popup" />


When user clicks on Open popup button i am calling openPopup() method in JavaScript which takes care of opening popup

3 comments:

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said...

Egmedi.com is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery


Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store