This is the snippet of my xhtml page.
<p:dataTable var="doc" value="#{orderCreationBackingBean.documentList}" reflow="true" style="width:70%;margin-top:5px;margin-top:5px;">
<p:column headerText="Document Name">
<h:outputText value="#{doc.documentName}"/>
<p:outputLabel value=" *" rendered="#{doc.docType == 'M' ? true : false}" style="color:red;"/>
</p:column>
<p:column style="width:20%;">
<p:fileUpload fileUploadListener="#{orderCreationBackingBean.handleFileUpload}" mode="advanced" skinSimple="true" sizeLimit="100000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/" update="tabView:idformexprocess" auto="true" uploadLabel="Upload"
onstart="submitCollection([{name:'docCode', value:'#{doc.documentCode}'},{name:'docName', value:'#{doc.documentName}'}])"/>
<p:remoteCommand name="submitCollection" process="@this" action="#{orderCreationBackingBean.setValuesForFileUpload}" partialSubmit="true"/>
</p:column>
<p:column style="width:20%;">
<p:commandButton value="View"></p:commandButton>
</p:column>
</p:dataTable>
In here, most of the times, onstart invokes after the fileuploadlistener.
These are the two methods I'm calling
public void setValuesForFileUpload() {
FacesContext context = FacesContext.getCurrentInstance();
Map<String,String> params = context.getExternalContext().getRequestParameterMap();
String doc = params.get("docCode");
docCode = new BigDecimal(doc);
docName = params.get("docName");
}
/**
* Upload Document in Dynamic Screen
*/
public void handleFileUpload(FileUploadEvent event) {
File obj = null;
InputStream inputStream = null;
if(event != null){
UploadedFile uploadFile = event.getFile();
try {
inputStream = event.getFile().getInputstream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(uploadFile.getFileName());
documentService.uploadTaskDocuments(username, avaOrderNo, bpmOrderNo, custOrderNo, bpmTaskNameAsID, docCode, event.getFile().getFileName(), uploadFile.getContentType(), uploadFile.getSize(), inputStream, "I", propFileReader.getApiQuery("UPLOADTASKDOCUMENTS"));
}
FacesMessage message = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, message);
}
What should I do to invoke onstart before the listener? Thank you in advance.