c0nazaa
asked on
Struts and pop up window
I need some urgent help
need to open a pop up jsp in from a parent jsp page. The pop up jsp should include two radio buttons - say delete all and delete this only. Then have a cancel and a delete button. I then need to pass the option value selected back to the parent page. In the parent page I will use the value of the option to send send in a form action for either deleteAll or delete.
I am new to struts and so I do not know what changes and where the changes need to be done. Can you please provide sample code for the pop up jsp and how it can be invoked from the parent jsp and additionally how can I then use that option to pass the necessary action to the Action class. What all changes will be required.
The parent jsp has a delete button to delete a record selected...when user clicks on this delete button on the parent page, the pop up window should provide delete options. When option selected close window (if possible) or click on cancel to close the window.
Please help!!!
thanks
need to open a pop up jsp in from a parent jsp page. The pop up jsp should include two radio buttons - say delete all and delete this only. Then have a cancel and a delete button. I then need to pass the option value selected back to the parent page. In the parent page I will use the value of the option to send send in a form action for either deleteAll or delete.
I am new to struts and so I do not know what changes and where the changes need to be done. Can you please provide sample code for the pop up jsp and how it can be invoked from the parent jsp and additionally how can I then use that option to pass the necessary action to the Action class. What all changes will be required.
The parent jsp has a delete button to delete a record selected...when user clicks on this delete button on the parent page, the pop up window should provide delete options. When option selected close window (if possible) or click on cancel to close the window.
Please help!!!
thanks
ASKER
Thank you for your prompt response as well as for the suggestions provided...
can you please me do some revisions...
basically, i want to just pass the action values of "DeleteAll" or "DeleteThisOnly" to the action class...depending on what the user selects...
For Add...I have a drop down...if selected index is 0, i need to provide a pop up which will then pass form action values of "addAll" or "addThisOnly" to the action class...
Currently parent jsp triggers submitSpocList javascript function
Please can you help correct me...
Parent JSP
function submitSpocList() {
alert("Selected SPOC value : "+document.forms[spocForm] .selectedS pocList.va lue);
if(document.forms[spocForm ].selected SpocList.v alue == 0 ){
addSpocScreen();
}
else{
document.forms["spocForm"] .formActio n.value = "SpocList";
document.forms["spocForm"] .submit();
}
}
function addSpocScreen(){
var url="<%=contextPath%>/SPOC InforMappi ngAction.d o?formActi on=openSpo cAddOption sScreen";
document.forms["spocForm"] .formActio n.value = "openSpocAddOptionsScreen" ;
if (typeof(popupWin) != "object"){
popupWin = window.open(url, "SpocAddOptionsScreen",
"width=300,height=400,resi zable=yes, scrollbars =yes,toolb ar=no,loca tion=no,st atus=no,me nubar=no") ;
}
else{
if (!popupWin.closed){
popupWin.location.href = url;
}
else{
popupWin = window.open(url, "SpocAddOptionsScreen", "width=300,height=400,scro llbars=yes ,toolbar=n o,location =no,status =no,menuba r=no");
}
}
}
function deleteSpocScreen(){
var url="<%=contextPath%>/SPOC InforMappi ngAction.d o?formActi on=openSpo cDeleteOpt ionsScreen ";
document.forms["spocForm"] .formActio n.value = "openSpocDeleteOptionsScre en";
if (typeof(popupWin) != "object"){
popupWin = window.open(url, "spocDeleteOptionsScreen",
"width=400,height=350,scro llbars=yes ,toolbar=n o,location =no,status =no,menuba r=no");
}
else{
if (!popupWin.closed){
popupWin.location.href = url;
}
else{
popupWin = window.open(url, "spocDeleteOptionsScreen",
"width=400,height=300,scro llbars=yes ,toolbar=n o,location =no,status =no,menuba r=no");
}
}
//var val =document.forms["spocForm" ].delOptio ns.value;
//alert("spoc delete option is "+val);
}
POP UP JSP ( same for add and delete)
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean. tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html. tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic .tld" prefix="logic" %>
<%
String contextPath = request.getContextPath();
String textClass = "etextField";
String actionPath = "SPOCInforMappingAction.do " ;
String formBeanName = "SPOCInforFormBean";
%>
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="<%=contextPath%>/ewi /ecpd/jsp/ ewiusage.c ss">
<script language="JavaScript" type="text/JavaScript">
function submitDeleteAll() {
alert("delete all called for spoc");
alert(document.forms["spoc Form"].sel ectedSpocL ist.value) ;
document.forms["spocForm"] .spocUpdat eOption.va lue=5;
document.forms["spocForm"] .formActio n.value = "DeleteAll";
document.forms["spocForm"] .submit();
window.close();
}
function submitDeleteThisOnly() {
alert("delete this only called for spoc");
alert(document.forms["spoc Form"].sel ectedSpocL ist.value) ;
document.forms["spocForm"] .formActio n.value = "Delete";
document.forms["spocForm"] .submit();
window.close();
}
function check() {
opener.document.forms["spo cForm"].fo rmAction.v alue = "refresh";
opener.document.forms["spo cForm"].su bmit();
window.close();
}
function cancel(){
window.close();
}
</script>
</head>
<!-- <body onload = "check()" > -->
<body>
<html:form action="<%=actionPath%>" styleId="spocForm">
<html:hidden property="formAction" />
<table width="100%" bgcolor="#6699cc" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="section-title" width="100%">SPOC Delete Options</td>
</tr>
<tr>
<td align="left">
<html:button property="deleteAllButton" styleClass="screenbutton" value="addAll" onclick ="submitDeleteAll()"/>
</td>
<td align="left">
<html:button property="deleteThisButton " styleClass="screenbutton" value="save" onclick ="submitDeleteThisOnly()"/ >
</td>
</tr>
<tr>
<td align="center">
<html:button property="cancelButton" styleClass="screenbutton" value="Cancel" onclick="cancel()"/>
</td>
</tr>
</table>
</html:form>
can you please me do some revisions...
basically, i want to just pass the action values of "DeleteAll" or "DeleteThisOnly" to the action class...depending on what the user selects...
For Add...I have a drop down...if selected index is 0, i need to provide a pop up which will then pass form action values of "addAll" or "addThisOnly" to the action class...
Currently parent jsp triggers submitSpocList javascript function
Please can you help correct me...
Parent JSP
function submitSpocList() {
alert("Selected SPOC value : "+document.forms[spocForm]
if(document.forms[spocForm
addSpocScreen();
}
else{
document.forms["spocForm"]
document.forms["spocForm"]
}
}
function addSpocScreen(){
var url="<%=contextPath%>/SPOC
document.forms["spocForm"]
if (typeof(popupWin) != "object"){
popupWin = window.open(url, "SpocAddOptionsScreen",
"width=300,height=400,resi
}
else{
if (!popupWin.closed){
popupWin.location.href = url;
}
else{
popupWin = window.open(url, "SpocAddOptionsScreen", "width=300,height=400,scro
}
}
}
function deleteSpocScreen(){
var url="<%=contextPath%>/SPOC
document.forms["spocForm"]
if (typeof(popupWin) != "object"){
popupWin = window.open(url, "spocDeleteOptionsScreen",
"width=400,height=350,scro
}
else{
if (!popupWin.closed){
popupWin.location.href = url;
}
else{
popupWin = window.open(url, "spocDeleteOptionsScreen",
"width=400,height=300,scro
}
}
//var val =document.forms["spocForm"
//alert("spoc delete option is "+val);
}
POP UP JSP ( same for add and delete)
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.
<%@ taglib uri="/WEB-INF/struts-html.
<%@ taglib uri="/WEB-INF/struts-logic
<%
String contextPath = request.getContextPath();
String textClass = "etextField";
String actionPath = "SPOCInforMappingAction.do
String formBeanName = "SPOCInforFormBean";
%>
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="<%=contextPath%>/ewi
<script language="JavaScript" type="text/JavaScript">
function submitDeleteAll() {
alert("delete all called for spoc");
alert(document.forms["spoc
document.forms["spocForm"]
document.forms["spocForm"]
document.forms["spocForm"]
window.close();
}
function submitDeleteThisOnly() {
alert("delete this only called for spoc");
alert(document.forms["spoc
document.forms["spocForm"]
document.forms["spocForm"]
window.close();
}
function check() {
opener.document.forms["spo
opener.document.forms["spo
window.close();
}
function cancel(){
window.close();
}
</script>
</head>
<!-- <body onload = "check()" > -->
<body>
<html:form action="<%=actionPath%>" styleId="spocForm">
<html:hidden property="formAction" />
<table width="100%" bgcolor="#6699cc" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="section-title" width="100%">SPOC Delete Options</td>
</tr>
<tr>
<td align="left">
<html:button property="deleteAllButton"
</td>
<td align="left">
<html:button property="deleteThisButton
</td>
</tr>
<tr>
<td align="center">
<html:button property="cancelButton" styleClass="screenbutton" value="Cancel" onclick="cancel()"/>
</td>
</tr>
</table>
</html:form>
ASKER
I managed to find something before your response came in and so posted the contents of that earlier to this...I am not sure how to go about putting in your changes...yours look simple...
the new pop up jsp should i have it included in the struts-config.xml...as well?
Again..thank you so much..please assist me when you get the time. Thanks
the new pop up jsp should i have it included in the struts-config.xml...as well?
Again..thank you so much..please assist me when you get the time. Thanks
You already have a project structure and don't have to change it by following my idea.
You are sending request to formAction in your Javascitpt function(not to request Popup jsp). I guess that you have to config your new pop up JSP in struts-config.xml and let action class forward request back to your Popup JSP. Does your Javascipt function work fine to popup new window? (I am home and have no J2ee IDE now)
You are sending request to formAction in your Javascitpt function(not to request Popup jsp). I guess that you have to config your new pop up JSP in struts-config.xml and let action class forward request back to your Popup JSP. Does your Javascipt function work fine to popup new window? (I am home and have no J2ee IDE now)
ASKER
Yes the javascript opens the new pop up window but it shows a pop up page as well as a pop up window. When I close it, it closes the browser window. The pop window also does not look good in terms of the buttons being scattered everywhere.......
For the add, is it possible to submit two actions within one javascript function??
For instance
function submitAddAll() {
alert("add all called for spoc");
if ( !checkString(document.form s["spocFor m"].firstN ame, "First Name", false))
return;
if ( !checkString(document.form s["spocFor m"].lastNa me, "Last Name", false))
return;
if ( !checkUSPhone(document.for ms["spocFo rm"].phone Number, false))
return ;
if ( !checkUSPhone(document.for ms["spocFo rm"].mobil eNumber, true))
return ;
if ( !checkUSPhone(document.for ms["spocFo rm"].faxNu mber, true))
return ;
alert(document.forms["spoc Form"].sel ectedSpocL ist.value) ;
document.forms["spocForm"] .formActio n.value = "SpocList";
document.forms["spocForm"] .submit();
document.forms["spocForm"] .spocUpdat eOption.va lue=4;
document.forms["spocForm"] .formActio n.value = "addAll";
document.forms["spocForm"] .submit();
window.close();
}
the window.close does not seem to be doing the right thing....
Any suggestions??
Thanks
For the add, is it possible to submit two actions within one javascript function??
For instance
function submitAddAll() {
alert("add all called for spoc");
if ( !checkString(document.form
return;
if ( !checkString(document.form
return;
if ( !checkUSPhone(document.for
return ;
if ( !checkUSPhone(document.for
return ;
if ( !checkUSPhone(document.for
return ;
alert(document.forms["spoc
document.forms["spocForm"]
document.forms["spocForm"]
document.forms["spocForm"]
document.forms["spocForm"]
document.forms["spocForm"]
window.close();
}
the window.close does not seem to be doing the right thing....
Any suggestions??
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok I will try your suggestion. Thank you very much for taking the time to address my question.
Anyway, in your parent JSP, delete button can trigger a javascript function like:
<input type="button" name="del_record" value="Delete" onClick="jsDelRecord(this.
In your javascript, you can popup JSP by this example:
function jsDelRecord(formName)
{
var theHref = "Popup.jsp?delRecordID="+f
view_window = window.open(theHref,'_blan
formName.submit();
return true;
}
Then, in your Popup.jsp, put passed record info in hidden before user select radio button about delete all ot delete this one