简体   繁体   中英

Cancel button behaves differently in Firefox and in Chrome

Note : A few hours back, I had posted this question in Javaranch also. The link for that is http://www.coderanch.com/t/629456/JSP/java/Cancel-button-behaves-differently-Chrome . I haven't received a response yet. I'm posting it here to see if I could get a suggestion or two. Also I am very beginner when it comes to struts and JSPs so please let me know if I should provide more details.

The problem is the cancel button on my web page behaves differently in chrome and in firefox browsers.

My current URL is context path/importEmployee.do?method=load.

In my current page, I upload a CSV file. This page has two buttons-- ok and Cancel and these buttons are what I'm having trouble with ( I will come to that part in a short while). The relevant JSP part is as follows.

 <html:form action="importEmployee?method=save" method="POST" styleId="importEmployee" enctype="multipart/form-data"> ....... some headers and title bar and stuff... and then as follows. <div class="contentSection"> <table border="0" class="formTable"> <html:hidden property = "selectedSet" /> <tr> <td class="formLabel"><label for="file">Download File:</label> </td> <td> <span> <a class="buttonStyle" rel="nofollow">Download Sample CSV</a> </span> </td> <tr> <td class="spacerCell"> </td> </tr> <tr> <td class="formLabel"><label for="file">CSV File:</label></td> <td><html:file property="importFile" styleId="importFile" size="60" maxlength="120" /></td> </tr> <tr> <td class="spacerCell"> </td> </tr> </table> </div> <table border="0" class="footerBar"> <tr> <td id="footerLeft"> <html:submit value=" OK " title=" OK " styleClass="button"> </html:submit> <span> <a class="buttonStyle" href="<%=request.getContextPath()%>/employees.do?method=load"> Cancel </a> </span> </td> <td id="footerRight" class="pagination"> </td> </tr> </table> 

Once I upload the CSV file and click on ok, the appropriate action class method is invoked and my url changes to - context path/importEmployee.do?method=save

This page basically contains the import statistics, error messages for unprocessed records and such things. This page also has an ok and a cancel button. The corresponding JSP parts are as follows.

 <html:form action="importEmployee?method=save" method="POST" styleId="importEmployee" enctype="multipart/form-data"> <table border="0" > <tr> <td id="leftEdge"><img src="<%= request.getContextPath()%>/images/new/edge_left.gif" width="30" 

height="321" alt="" />

  ..... some processing and then... <table border="0" class="footerBar"> <tr> <td id="footerLeft"> <span> <a class="buttonStyle" href="<%=request.getContextPath()%>/employees.do?method=load"> OK </a> </span> <input name="cancel" id="cancel" type="submit" class="button" value="Cancel" onclick="goBack(); return false;" /> </td> <td id="footerRight" class="pagination"> </td> </tr> </table> 

So, if I click on cancel in the second page (context path/importEmployee.do?method=save), I go back to the first URLpage, ie to context path/importEmployee.do?method=load. But this part behaves differently in Firefox and in Chrome browsers. In Chrome, if I click on cancel in the second page, I can still see the uploaded file name( the hidden property in the first JSP is the file name ) in the first page. And if I click on ok, I can do the processing again as was done by clicking ok the first time on the first page. However when I run my application in a Firefox browser, if I click on cancel in the second page, the uploaded file name says 'no file selected' in the first page. Hence to import Employees again, I need to upload a new/same CSV file again.

I don't want the file to be present in the first page when I click on cancel in the second page even when I run my application in Chrome. Yes, I require the file name to be a hidden property. This is because depending on the data in the file, different kind of processings are done and some of them require to take additional inputs from user on another page and a third page does the processing. So the file name should be passed on to the form but I don't want the user to upload the file again.

However in the event the user clicks on cancel, I don't want the file name to be retained in the first page. But this isn't happening.

So I have two questions. Why is the behaviour different in Chrome and in Firefox and is there a way I can correct the way it behaves in chrome?

This is resolved.

Folks at work said that this cancel button behaviour is a known behaviour. Seeing the file name again after clicking cancel in chrome is ok. We shouldn't see it in Mozilla.

Sorry for the confusion and thanks for going through my question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM