aspose file tools*
The moose likes Struts and the fly likes action class gets skipped when opening link via javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "action class gets skipped when opening link via javascript" Watch "action class gets skipped when opening link via javascript" New topic
Author

action class gets skipped when opening link via javascript

K Dombroski
Ranch Hand

Joined: Dec 03, 2005
Posts: 39
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?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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().


Merrill
Consultant, Sima Solutions
K Dombroski
Ranch Hand

Joined: Dec 03, 2005
Posts: 39
Ok, thanks so much for the explanation!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: action class gets skipped when opening link via javascript