my dog learned polymorphism*
The moose likes JSP and the fly likes window.close(); and Form submit problem in JS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "window.close(); and Form submit problem in JS" Watch "window.close(); and Form submit problem in JS" New topic
Author

window.close(); and Form submit problem in JS

shankha bhattacharya
Greenhorn

Joined: Apr 20, 2007
Posts: 12
Hi,
I am facing a problem for Form submitting using java script.

JS code is :

function onClickAddTransRecv()

{

// actionType is the hidden variable in the JSP page.

document.TransRecvInfoForm.actionType.value = "addTransRecvSubmit";

document.TransRecvInfoForm.submit();

//window.alert("TransRecvInfoForm form submitted");
OR
// alert("TransRecvInfoForm form submitted");

window.close();
OR
self.close();
}

In the action class I try to fetch the value of actionType using

String sAction = (String) request.getParameter("actionType");



Using this code when I submit the form in the Action class I get the value of "actionType" is null instead of "addTransRecvSubmit".

But if I use "window.alert" OR normal "alert" between Form submission and window closing I get the value of "actionType" is "addTransRecvSubmit" in the Action class.

Please help
Vivek Ramanath
Greenhorn

Joined: Apr 23, 2007
Posts: 4
Check in the form class whether you have a getter/setter method for the variable.Try putting a request.getParameter inside the action class.If you are getting the value in request.getParameter and not otherwise.then getter/setter is the problem.Please check the same and revert
shankha bhattacharya
Greenhorn

Joined: Apr 20, 2007
Posts: 12
yes I already used

String sAction = (String) request.getParameter("actionType"); in my action class to get the value but still getting null.

I can only avoid the problem if I put alert or window.alert(" .. ") message
between form submit and window.close().

- so still I have the problem --
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: window.close(); and Form submit problem in JS