I built this sample portlet to demonstrate what i mean. My Sample portlet has a popup.jsp and when ever you click on open popup.jsp button it opens popup.jsp in dialog box, i am passing userName parameter to the JSP. You can download the sample code for portlet from here
THe doView() method of sample portlet forwards control to index.jsp which looks 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 />
<script type="text/javascript">
<!--
function openPopup(popupUrl){
if (window.showModalDialog) {
window.showModalDialog(popupUrl,"name","dialogWidth:455px;dialogHeight:450px");
} 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('<%=renderResponse.encodeURL(renderRequest.getContextPath() + "/popup.jsp?userName=poup.jsp") %>')"
value="Popup.jsp" />
<br/>
I am creating URL to a JSP which resides in same portlet application like this
renderResponse.encodeURL(renderRequest.getContextPath() + "/popup.jsp?userName=poup.jsp")
. I am passing userName as parameter to the popup.jsp, i used a JSP but it can be a servletTHis is how my poup.jsp looks like
<html>
<body>
Hello from popup.jsp
<h1><%= request.getParameter("userName") %></h1>
</body>
</html>
The popup.jsp is pretty simple, all that it does is read value of userName request parameter and print it in HTML
2 comments:
how to open external site open in dialog like 'google'
Thanks for info
Web Design Company in Bangalore
Website development in Bangalore
Post a Comment