*
The moose likes Struts and the fly likes Problem in window.close; page get requested again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem in window.close; page get requested again" Watch "Problem in window.close; page get requested again" New topic
Author

Problem in window.close; page get requested again

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
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

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


Merrill
Consultant, Sima Solutions
 
jQuery in Action, 2nd edition
 
subject: Problem in window.close; page get requested again
 
Similar Threads
iframe and struts url won't work
Cannot retrieve mapping for action /content/AddLinks
DispatchAction error .... NoClassDefFoundError...
ClassCastException in struts - urgent! :(
calling action while loading the home page