在primefaces上传后,重新加载jsf页面有什么用?
我尝试使用javascript oncomplete =“javascript:window.location.reload()”,但它不起作用:
XHTML:
豆:
public void upload(FileUploadEvent event) throws SQLException {
LoginAuthentication user = new LoginAuthentication();
FacesMessage msg = new FacesMessage("Success! ",event.getFile().getFileName()
+ " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null,msg);
// Do what you want with the file
try {
copyFile(event.getFile().getFileName(),event.getFile().getInputstream());
ConectaBanco mysql = new ConectaBanco();
mysql.insere("INSERT INTO edicoes VALUES (NULL,'"
+ mysql.pegaIDrev(user.getNome())
+ "',NULL,'"
+ event.getFile().getFileName()
+ "' );");
File pasta = new File(caminhoPastaPDF
+ "/convertidos/"
+ event.getFile().getFileName());
pasta.mkdir();
convertePdf(event.getFile().getFileName());
FacesMessage msg1 = new FacesMessage("Succesful",event.getFile().getFileName()
+ " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null,msg1);
} catch (IOException e) {
e.printStackTrace();
}
}
public void copyFile(String fileName,InputStream in) {
try {
// write the inputStream to a FileOutputStream
OutputStream out = new FileOutputStream(new File(destination + fileName));
int read = 0;
byte[] bytes = new byte[1024];
while ((read = in.read(bytes)) != -1) {
out.write(bytes,read);
}
in.close();
out.flush();
out.close();
////System.out.println("New file created!");
}
}
还有其他方法吗?
我想刷新< a4j:重复>
最佳答案
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。