Win a copy of Rust Web Development this week in the Other Languages 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Problem in window.close; page get requested again

Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am displaying certain information to user (say showContent.jsp) which is pop up window.
In this page showContent.jsp the user has the option to download the content and close the window, using download and close button. Based on the button clicked, i call either window.close or window.submit.

But the problem is whenever i click the close button and tried to close the window using window.close(), the page is get submitted to the previous request.
i.e Say from a parent window through link i am requesting for ShowContent(/showContent is the request path which i handled in Action mapping and pass the request to this showContent.jsp).
Then showContent.jsp is displayed to the user in a pop-up.
And when i clicked close button, the window is closed but from the log file,
i found out that again a request for /showContent is triggered. but the UI is fine.

i pasted all the code that are involved in this process..

Java Script function

Snippet from JSP page..

my struts config.xml:

Any pointers...
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An <html:submit> buttton will submit the form no matter what you do in the JavaScript specified in the onsubmit event. If you don't want to submit the form under some conditions, don't use the <html:submit> button. Here's what I'd suggest:

1- Remove the onsubmit event from your form.
2- Change your first button to:
<html:button property="method" onklick="closeWindow()">
<bean:message key="button.close"/>
Hot dog! An advertiser loves us THIS much:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic