Primefaces(3.5)FileUpload组件无法将上载的文件名更新为OutputText组件

时间:2013-07-16 02:32:10

标签: jsf-2 primefaces xhtml netbeans-7 mojarra

您好我使用的是netbeans IDE 7.2,primefaces 3.5,glassfish server 3.1.2,mojarra 2.1.6。

我使用outputText组件在上传后显示上传文件的名称。但是,从未更新outputText组件以显示文件名。请帮助。

我有这个xhtml页面:

<h:form enctype="multipart/form-data">
   <p:ajaxStatus>
       <f:facet name="start">
           <h:graphicImage value="images/loading.gif" />
       </f:facet>
       <f:facet name="complete">
        <h:outputText value="" />
       </f:facet>
   </p:ajaxStatus>
   <h:outputText value="#{bundle.AttachmentLabel}"/>
   <p:fileUpload fileUploadListener="#{testingPage.handleFileUpload}"
                 allowTypes="/(\.|\/)(doc|docx|ppt|pptx|xls|xlsx|pdf)$/"
                 update="attachmentname"/> 
   <h:outputText value="#{bundle.AttachmentLabel} #{bundle.YangLabel} #{bundle.AlreadyLabel} #{bundle.UploadedLabel}"/>
   <h:outputText id="attachmentname" value="{testingPage.attachmentfilename}"/>                            
</h:form>

这是我的ViewScoped支持bean的handleFileUpload监听器:

public void handleFileUpload(FileUploadEvent event) {
try {
       LogController.log.info("Assign attachment variable to event file property");
       attachment = event.getFile();
       LogController.log.info("Assign attachment byte to attachment contents");
       attachmentbyte = attachment.getContents();
       LogController.log.info("Assign attachment file name to attachment file name");
       attachmentfilename = attachment.getFileName();
    } catch (Exception ex) {
       LogController.log.fatal(ex.toString());
    }
}

可能有什么不对? Primefaces展示完美。请帮忙。谢谢。

0 个答案:

没有答案