Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2006, 06:32 PM
Registered User
 
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.








Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get linkname from jsp to struts action clas mona_1dec Struts 2 May 2nd, 2007 01:04 AM
How to display errors from Action class on the jsp ntando HTML Code Clinic 0 December 5th, 2006 06:30 PM
<jsp:useBean> action problem austinf JSP Basics 1 August 21st, 2006 04:23 PM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM
JSP Beans Errors harshadriswadkar JSP Basics 0 September 30th, 2003 06:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.