2015-09-23 25 views
0

我必須上傳CSV文件,並且必須驗證文件的某些值,例如不允許負值。然後,我需要驗證它,並且該文件不會像「完成」或「上傳」一樣。我需要處理顯示它的錯誤。顯示錯誤並更改richLabel:上傳偵聽器方法中的fileUpload

<rich:fileUpload 
    fileUploadListener="#{configClientBean.listener}" 

    ontyperejected="alert('some error');" 
    maxFilesQuantity="1" 
    onuploadcomplete="#{rich:component('waitPanelInterno')}.hide();" 
    onfilesubmit="#{rich:component('waitPanelInterno')}.show();" 
    render="pnlMensajes, idTableClients, scrollRegistros, outputPanelDetalle" 
    autoclear="true"> 

    <rich:message for="uploadConfigClient" /> 

    <a4j:ajax event="uploadcomplete" execute="popupFileLoad" 
    render="panelCarga, pnlMensajes" /> 

</rich:fileUpload> 

在支持bean我可以驗證一些事情,但我不能顯示錯誤或改變「富:文件上傳」行爲不能顯示例如doneLable成分,它。

public void listener(FileUploadEvent event) throws Exception { 

    try { 
     UploadedFile file = event.getUploadedFile(); 
     ByteArrayInputStream bais = new ByteArrayInputStream(file.getData()); 
     InputStreamReader is = new InputStreamReader(bais, getMessage("iso")); 
     BufferedReader bufRead = new BufferedReader(is); 
     while ((registro = bufRead.readLine()) != null) { 
      if(cvsLine[1].isEmpty()){ 
      // stop process 
      // Throw error 
      } 
     } 
} 

謝謝你的時間。

+0

請詳細說明「我不能顯示錯誤」。你究竟怎麼不能顯示錯誤?究竟發生了什麼? – BalusC

回答