Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

updating ArrayList on parent from child window

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. This is my first time on this forum and unfortunately I don't have example code to illustrate my problem, so I have a rather lengthly explanation. Please look at it as I have been rocking my brains for a week now. Thanks.

1) parent and child have own Action and ActionForm classes, all with scope=request; scope=session is not really an option.
2) parent JSP that renders parent ActionForm contains 5 elements:
1) text box to enter a group name
2) text box for effective date
3) text box for expiration date
4) <table> with <logic:iteration id="assgndAM" index="iAssgndAM"> to render contents of ArrayList<AccountManager>. This ArrayList is an instance variable on the parent ActionForm bean and uses Lazy List processing to automatically grow the ArrayList. This is done when parent ActionForm is loaded the first time and subsequent times.
a) four fields displayed: <html:checkbox>, and 3 text boxes.
5) <input type=button onclick=addToGroup()>
a) JavaScript linked to parent JSP that opens a new window and passing "childAction.do" and a string concatenation of all the elements to be displayed.
b) string parameter of all elements is loaded into ArrayList of the child ActionForm bean when childAction is called.
3) child JSP that renders child ActionForm contains three elements
1) <table> with <logic:iteration id="assgnAbleAM" index="iAssgnAbleAM">. This too is an ArrayList<AccountManager> as a instance variable on the child ActionForm bean.
a) three fields displayed in table: <html:checkbox>, and two text boxes.
2) <input type=button value="Add" name="Add onClick="addManagers()">
a) user presses button and passes all the items checked from table as a string to parent Action using document.form.action=parentAction.do. Parent Action grows and loads ArrayList<AccountManager> with string parameter contents.
3) <input type=button value="Cancel"> closes the popup window.
4) process flow:
1) user goes to parent JSP and enters data in text boxes.
2) user presses "Add To Group" button on parent JSP which launches child popup window.
3) user checks people to add to group and presses "Add" button on child popup window. Popup closes.
4) parent JSP now shows items checked from child window.
5) user presses "Add To Group" button on parent JSP again to add more.
5) problem is on subsequent adds because of scope=request, new parent ActionForm is being created and ArrayList<AccountManager> is empty. However, the three other instance variables, which are associated to the text boxes on the main JSP, are populated on parent ActionForm bean. Bottom line, I am losing the contents of the ArrayList<AccountManager> everytime after the first time when going from child to parent.






 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't help you much without knowing the code.
But if this is your problem,

Nick Gatsis wrote:5) problem is on subsequent adds because of scope=request, new parent ActionForm is being created and ArrayList<AccountManager> is empty.


the use session scope.
 
There's a way to do it better - find it. -Edison. A better tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic