how to display errors on jsp from action
Hi,
I have 2 jsps exceptionsList.jsp and feecompute.jsp
on clicking a button in exceptionsList.jsp i call
var ret = window.showModalDialog(appRoot + "/exceptionHandling.do?actionType=displayExcDet&flg= "+taskname, "AdHoc Portal", "dialogWidth:700px;dialogHeight:670px;help:no;scro ll:yes;status:yes;resizable:yes;");
return;
This opens up the feecompute.jsp.
feecompute.jsp contains a struts form.
On clicking the save button , I do
var formToPost = "excHandlingActionForm";
var str = formPOST(formToPost, url);
alert(str);
return;
The Action class returns some errors, now i want to display these errors to the user on the same jsp or the a new jsp.
My problem is that when i do the alert(ret), i can see the expected result in it.
but a new jsp does not opens up neither the current jsp refreshes.
The code for formPost is
function formPOST(frm, url) {
var str = buildPOST(frm);
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", url, false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(str);
return xmlhttp.ResponseText;
}
function buildPOST(formName) {
var frm = document.forms[formName];
var POSTdata = "";
var type = "";
var on = false;
var value = "";
for (var i = 0; i < frm.elements.length; i++) {
var name = frm.elements[i].name;
if (frm.elements[i].type) {
type = frm.elements[i].type;
type = type.toLowerCase();
if (type == "checkbox") {
on = frm.elements[i].checked;
if (on==true){
value = escape(frm.elements[i].value);
}
else {
value = "";
}
}
else {
value = escape(frm.elements[i].value);
}
}
else {
value = escape(frm.elements[i].value);
}
if (name != "") {
if (POSTdata == "") {
POSTdata = name + "=" + value;
}
else {
POSTdata += "&" + name + "=" + value;
}
}
}
alert(POSTdata);
return POSTdata;
}
Now when i do something like below it works, but the window opened is not a modal one.
//document.excHandlingActionForm.action = url;
//document.excHandlingActionForm.submit();
//window.close();
can anyone help me in getting a modal window in which the errors are displayed.
|