It's not a secret anymore!*
The moose likes Servlets and the fly likes URGENT Help Needed ...!! 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 » Servlets
Bookmark "URGENT Help Needed ...!! " Watch "URGENT Help Needed ...!! " New topic
Author

URGENT Help Needed ...!!

Seema Hanji
Ranch Hand

Joined: Jan 29, 2001
Posts: 37
Hi All ,
I have a JSP page that gets data from database and displays.
One of the Form fields(It is a Drop down box.) on this page has a 'Edit' button . This field is populated with data from a bean which has session scope(jsp:useBean id="..." class="java.util.Vector" scope="session").
When this 'Edit' is pressed , it brings up a popup JSP page (using Javascript window.popup), which has a Table of INPUT fields filled with values from drop down box, and hence allowing user to modify them .
This JSP also has bean with same id as 1st page , hence has access to values of this bean . This Page has a submit button to submit data after modification.
So , on submit ,
1> I need to update the session bean,
How do I do it in JSP ??? . I can only access form field values through Javascript right ??
Right now , I am sending request to a servlet , which is copying form field values to session variable, and then sending request to first JSP page.
2> close the popup window.
I am trying to close widow in Javascript after submit,
form.submit();
window.close();
It doesn't work.
3> and refresh first window with updated bean contents.
Please help me in this , Any suggession is welcome.
Thanks in advance.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Hi,
First seems to be right,
then you do:

form.submit(); //submit your form
opener.location.reload(); /*update your page. May be better if servlet, that updates your bean will set some value to session, and your JSP will check this value, and ig it set, update contents and remove this value.*/
setTimeout("self.close()", 100); // close your page, but give
// your browser some time
Seema Hanji
Ranch Hand

Joined: Jan 29, 2001
Posts: 37
Thanks Yuriy,
I tried using opener.location.reload() , in IE it brings up a warning dialog before reload, and even worse in Netscape , it's throwing "NullPointerException" ... So I have dropped the idea of reloading , instead I am updating opener window dropdown list manually in 2nd JSP before submit , by accessing each option element thru javaScript.
Now I am facing problem , creating new "option" element using Javascript.., this question may be out of scope for this forum.
-Thanks anyway

Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Following code add option to select:
var opt = new Option('text', 'value');
document.formName.selectName.options[document.formName.selectName.options.length] = opt;
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
What you could also do, is:
your servlet, where you submit the form, could produce the code, that reload opener and close this popup window. I think it will work much better
Seema Hanji
Ranch Hand

Joined: Jan 29, 2001
Posts: 37
I could create new option in Netscape , but not in IE .
Getting "server error" on IE.
Is there different approach for creating new Option on IE ...??
Thanks for your continued help.
Originally posted by Yuriy Fuksenko:
Following code add option to select:
var opt = new Option('text', 'value');
document.formName.selectName.options[document.formName.selectName.options.length] = opt;

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URGENT Help Needed ...!!