Quote:
Originally Posted by acoder
Welcome to The Scripts.
The method you have described should work fine. Please post your code (in code tags).
Hi acorder,
Please find the code as followa :
1] My JSF page has a command button which has an action attribute and invokes a metod in the backing bean where I open a pop up.Please find the code to open pop up as follows -
String windowWidth = "575";
String windowHeight = "250";
html.append("<HTML>");
html.append("<TITLE></TITLE>");
html.append("<HEAD>");
html.append("<SCRIPT LANGUGE=\"JavaScript\">");
html.append("function windowOpen(){");
html.append("window.open('/web-swaf/faces/steel247/dh/jspf/Sendrequest.jsp','RequestScope',"
+ "'left=200,top=250,height="
+ windowHeight
+ ",width="
+ windowWidth
+ ",location=no,scrollbars=no,"
+ "menubars=no,toolbars=no,resizable=yes');");
html.append("form2.submit();");
html.append("}");
html.append("</SCRIPT>");
html.append("</HEAD>");
html.append("<BODY onLoad=\"windowOpen()\">");
html.append("<form name=\"form2\">");
html.append("</form>");
html.append("</BODY>");
html.append("</HTML>");
2] Now in the jsp - Sendrequest.jsp i do the following -
<SCRIPT language="javascript1.1">ajaxFunction()</SCRIPT>
<SCRIPT>
function ajaxFunction()
{ var xmlHttp;
alert("in ajax function");
try
{
xmlHttp=new XMLHttpRequest(); }
catch (e)
{
try
{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e)
{ try
{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e)
{ alert("Your browser does not support AJAX!");
return false; } } }
alert("Before action methods");
xmlHttp.open("GET","/RequestScopeServlet",true);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
alert("After action methods");
}
function callback() {
switch (xmlhttp.readyState){
case 1:
alert("Inside onLoading 1");
break;
case 2:
alert("Inside onLoaded 2");
break;
case 3:
alert("Inside onInteractive 3");
break;
case 4:
this.parent.refresh();
alert("Inside Complete 4");
me.close();
break;
}
}
</SCRIPT>
It should enter the forth Case and close the pop up. but my servlet is not invoked where i am executing my business methods.
Thanks in advance for any inputs on this.