Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URGENT Help Needed ...!!

 
Seema Hanji
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic