I have 2 forms one of them uploadForm which upload files and do some actions. After upload, I get an error on the console, when I submit save button:
- Uncaught TypeError: Cannot read property 'length' of null
- jsf.js:578 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/. (program):1
- Uncaught TypeError: Cannot read property 'debug' of undefined
I found related topics on this issue but still cant solve this. I didn't work with upload so i confuse here. All I need is update tables form on each save button invoke.
<h:form id="uploadForm" prependId="true" enctype="multipart/form-data">
<center>
<p:tabView id="alltabs">
<p:tab id="tabupload" title="Upload File">
<h:outputText value="Choose Microsoft Excel or TXT file to import (.xls or .xlsx or .txt) "/>
<p:fileUpload id="uploaddatafile"
style="width: 350px"
value="#{addbookCnt.uploadedFile}"
fileUploadListener="#{addbookCnt.handleFileUpload}"
mode="advanced"
sizeLimit="1000000"
allowTypes="/(\.|\/)(xls|xlsx|txt)$/"
fileLimit="1">
</p:fileUpload>
<h:commandButton id="btnSubmit" actionListener="#{addbookCnt.utest()}" value="Save">
<f:ajax execute="@form alltabs tabupload " render="@all"/>
</h:commandButton>
</h:panelGrid>
</h:panelGrid>
</p:tab>
</p:tabView>
</center>
</h:form>
<h:form id="tables">
</h:form>
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;
@ManagedBean(name = "addbookCnt")
@ViewScoped
public class ABController implements Serializable {
private UploadedFile uploadedFile;
public void handleFileUpload(FileUploadEvent event) {
LOG.info("handle file upload");
uploadedFile = event.getFile();
}
public void utest() {
LOG.info(uploadedFile.getFileName());
}
public UploadedFile getUploadedFile() {
return uploadedFile;
}
public void setUploadedFile(UploadedFile uploadedFile) {
this.uploadedFile = uploadedFile;
}
}
<f:fileUpload>
is the culprit and not your own ignorance somewhere else? Try using a single<p:fileUpload>
in a separate XHTML file ignoring the whole mess of other XHTML tags. – Tiny<h:commandButton>
with the enhanced PrimeFaces<p:commandButton>
but that's a story apart. You may want to debug further about what JavaScript file(s) is causing the error. – Tiny