प्राइमफ़ेस अपलोड करने के बाद जेएसएफ पेज को फिर से लोड करने का क्या हो सकता है?प्राइमफेस अपलोड करने के बाद जेएसएफ पेज को फिर से लोड करें?
मैं जावास्क्रिप्ट oncomplete="javascript:window.location.reload()"
के साथ प्रयास करें, लेकिन यह काम नहीं करता है:
एक्सएचटीएमएल:
<h:form>
<p:messages showDetail="true"/>
<p:fileUpload fileUploadListener="#{revistauploadBean.upload}"
mode="advanced" dragDropSupport="false" merge="true"
uploadLabel="Enviar" cancelLabel="Cancelar"
oncomplete="javascript:window.location.reload()"
label="Procurar PDF" sizeLimit="1000000000" fileLimit="3"
allowTypes="/(\.|\/)(pdf)$/" />
</h:form>
बीन:
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, NULL, NULL, 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, 0, read);
}
in.close();
out.flush();
out.close();
////System.out.println("New file created!");
}
}
वहाँ ऐसा करने के लिए एक और तरीके हैं ? मैं एक <a4j:repeat>
uumm को अपडेट करने का उपयोग करते हैं तो यह काम नहीं करेगा, इसे "जावास्क्रिप्ट:" के बिना आज़माएं। यह एक रीलोड करने में सक्षम होना चाहिए। लेकिन आपको शायद समस्या होगी कि आप गलत यूआरएल के साथ पेज को फिर से लोड करेंगे। यदि आप नेविगेट नहीं करते हैं? चेहर-रीडायरेक्ट = सत्य, तो आपका यूआरएल हमेशा एक पेज से पीछे हट जाएगा – noone