My FileDownload Ability now works. But still one problem occurs:
I represent the uploaded Files in a Datatable. There is also a delete Button,
which moves the file into an "old" directory.
When I now first open the file with the open button and THEN afterwards I want
to delete the file, i get the little window for opening the file AGAIN?
(Nevertheless the file is moved into the old directory...)
I have no found out, that the problem occurs because of a Confirm Message which
I have on the JSF Page:
If I delete the onclick="Return confirmSubmit()" Javascript Function, then
everything works...
Is there a possiblity to "Kill" the former submit, so that it doesn't come up
again?
Here is the JSF PAGE CODE:
<h:commandButton onclick="return confirmSubmit()"
image="images/loeschen.gif"
action="#{detailsDto.deleteDatenblaetter}">
<t:updateActionListener
property="#{detailsDto.dashId}"
value="#{rowItem[0]}" />
<t:updateActionListener
property="#{detailsDto.uploadFileDirectory}" value="#{rowItem[3]}" />
<t:updateActionListener
property="#{detailsDto.uploadFileName}"
value="#{rowItem[4]}" />
</h:commandButton>
Here is the code for deleting the Datasheet:
public void deleteDatenblaetter() throws Exception {
Session session = HibernateUtil.currentSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
EtDatasheets datasheet = (EtDatasheets) session.get(
EtDatasheets.class, dashId);
session.delete(datasheet);
File newdirectory = new File(directory +
"old\\datasheets");
newdirectory.mkdirs();
//String sNewFile = uploadFileDirectory.substring(5);
String sNewFile = uploadFileDirectory;
File in = new File(sNewFile);
FileInputStream fis = new FileInputStream(in);
File out = new File(directory + "old\\datasheets\\"
+ new Date().getTime() + "_" +
uploadFileName);
FileOutputStream fos = new FileOutputStream(out);
byte[] buf = new byte[1024];
int i = 0;
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
fis.close();
fos.close();
in.delete();
tx.commit();
}
catch (Exception ex) {
if (tx != null)
tx.rollback();
msg = bundle.getString("errorDeleteDatasheet");
context.addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_WARN, msg, null));
throw ex;
}
finally {
HibernateUtil.closeSession();
}
}
Thx for help!
Regards,
Andy
______________________________________________________________________
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
your system manager.
This footnote also confirms that this email message has been swept
for the presence of computer viruses.
______________________________________________________________________