This week's book giveaway is in the Functional programming forum.
We're giving away four copies of Functional Design and Architecture and have Alexander Granin on-line!
See this thread for details.
Win a copy of Functional Design and Architecture this week in the Functional programming 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

action class gets skipped when opening link via javascript

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to open a page in a new window, using the window.open method in javascript.


Everything works fine, except when I leave the window and click on the link again. When I do that, it goes to the correct page but completely skips the action class, so any data that might have been changed is not displayed--the user is seeing an old copy of the page.
To clarify, here are the steps taken:
1: click on link--new window opens with list of items displayed on page
2: go through process in new window to add an item to the db, but do not click the button to go back and re-display the list.
3: leaving window open, go to main application window and click on the link again--focus is changed to the child window, the correct action mapping is called (so the correct page is displayed), but the action class is never hit. The list of items does not contain the new item I just added.
How is this possible? The only explanation I can come up with is that it is caching the page, but I added


to my jsp template, and it doesn't make any difference.
The only solution I have come up with is to essentially call it twice:


This makes it so it will always go through the action class at least once, but unfortunately, also means that it often goes through it twice (i.e. when first clicking on the link), which is a performance problem.
I can't seem to find anything on Google that addresses this. Does anyone have a clue as to what the problem is and how I can fix it?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JavaScript window.open() function does excatly that: it opens a window. If the window is already open, it moves the focus to that window, but it does not refresh the window. That's why your Action class is not getting called.

My suggestion would be to add logic to your function to see if a child window is already open, and if it is, refresh the window rather than calling window.open().
 
K Dombroski
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thanks so much for the explanation!
 
You showed up just in time for the waffles! And this 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
reply
    Bookmark Topic Watch Topic
  • New Topic