Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in window.close; page get requested again

 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
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...
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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"/>
</html:button>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic