Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

opening popup window conditionally

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a JSP called "ABC.jsp", when I click "View Item" button it should call corresponding action class,process and display results(displayitems.jsp) in a popup window. for some reason if the result is error page or login page then the popup window should not be opened rather it should replace ABC.jsp in main window.

i.e.
If result is displayitems.jsp I want to open this jsp in pop up window and keep ABC.jsp open in main window.
If result is some other page I want to replace ABC.jsp with result page in main window.

how to do this opening the popup window conditionally i.e. based on result page?

Your response is appreciated!
Thanks
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You really can't do it in quite this way. The problem is that you must decide where the result is to be displayed before you submit. You can't change your mind once the submit has already occurred.

I can think of work-around solution, though. There is a way to tell whether or not the current window is a popup window. If it is a popup window, the property window.opener will have a value other than null. Otherwise, it will be null.

In your error page in the body's onload event, test window.opener to see if it's null. If it isn't null (meaning this is a popup window), cause the main window to load the error page (window.opener.location.replace('error.jsp');) and close the current window.
[ March 01, 2006: Message edited by: Merrill Higginson ]
 
Vaithiya Sundaram
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Merrill.

I had also tried exactly what you suggested:

In your error page in the body's onload event, test window.opener to see if it's null. If it isn't null (meaning this is a popup window), cause the main window to load the error page (window.opener.location.replace('error.jsp') and close the current window.



But the problem is, there are some on the fly validation messages(generated by struts validation.xml) which I am missing while displaying login.jsp page in case of the above scenerio.
(window.opener.location.replace('login.jsp')

do you have idea how to display whatever page we are getting for popup window to main window?

Thank you
vaidya
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic