Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

action class gets skipped when opening link via javascript

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Ok, thanks so much for the explanation!
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic