Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to persist data of child window form

 
Sameer Ahmed
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to do the following.

On clicking a button in the main JSP a new child window should open and in the child window there is a small form, on pressing the OK button on the form the child window should close and the data should persist in the bean. now on clicking the submit button main JSP the data of child window should be saved in the database.
How can I do this. ?
I have created separate action class and bean for child window, but the data does not persist in the bean after clicking the OK button.

I am using struts 2
 
Santhosh ayiappan
Ranch Hand
Posts: 80
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can think of the following,

1. When you click on the submit button of the child window, invoke a action class. In the action class create a method to map the values from the child windows form bean to parent windows form bean. Once the mapping is done, forward your request to the parent window which would have the values of your child window as well.

2. Have hidden fields in your parent window for all the fields that you might have in your child window. Use Java script to populate the values down to the parent window from the child window as soon as the onclick of the child windows submit button is triggered.


 
Sameer Ahmed
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i have 14 jsps and one common child window, so i cannot have the chiild window attibute in all 14 jsp beans.

i have another question.
How can open a child window WITHOUT refeshing/reloading parent window ?
I want to open a child window by clicking a submit button and not a link.
am using window.open ut it refrshes my parent window.

please help
 
Santhosh ayiappan
Ranch Hand
Posts: 80
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"actually i have 14 jsps and one common child window, so i cannot have the chiild window attibute in all 14 jsp beans. "

Create a class that has the attributes of the child window and extend this class in all the 14 parent JSP's.

 
Santhosh ayiappan
Ranch Hand
Posts: 80
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you paste the code you have written to open the child window ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic