【发布时间】:2019-10-15 09:46:14
【问题描述】:
我正在处理需要使用primefaces中的fileupload组件上传文件并在同一页面上使用documentViewer组件显示相同文件的要求。
<h:form enctype="multipart/form-data">
<p:fileUpload value="#{basicDocumentViewerController.file}" mode="simple"></p:fileUpload>
<p:separator/>
<h:commandButton value="Upload file" action="#{basicDocumentViewerController.dummyAction}">
</h:commandButton>
<p:tabView>
<p:tab title="Display content of the file">
<pe:documentViewer id="documentViewer" height="500" value="#{basicDocumentViewerController.content}" />
</p:tab>
</p:tabView>
</h:form>
在上传操作成功完成之前,文档查看器组件应该被禁用或不可见。上传操作后,内容应使用监听器显示在文档查看器中。你能帮助实现这一目标吗
【问题讨论】:
-
您不需要
p:tabView来实现这一点。将rendered="#{not empty basicDocumentViewerController.content}"添加到您的pe:documentViewer。或者甚至更好地向您的 bean 添加一个布尔属性,如果存在文档,则返回 true 并在rendered属性中询问。 -
我暗示您的解决方案是可行的,只要您没有说明“直到上传操作成功完成,文档查看器组件应该被禁用或不可见”旁边的特定问题。
标签: primefaces primefaces-extensions