jsf - 在 Primefaces Extensions documentViewer 中加载内容
问题描述
我正在像这样将 StreamedContent 加载到文档查看器中。
xhtml:
<h:body>
<h:form>
<p:commandButton value="Content A" action="#{viewer.selectContentA()}" update="viewerForm" />
<p:commandButton value="Content B" action="#{viewer.selectContentB()}" update="viewerForm" />
</h:form>
<h:form id="viewerForm">
<pe:documentViewer value="#{viewer.content}" download="demo.pdf" height="500"/>
</h:form>
</h:body>
豆:
public void selectContentA() {
content = contentA;
}
public void selectContentB() {
content = contentB;
}
public StreamedContent getContent() {
return content;
}
问题: 有没有办法在不更新整个组件的情况下更改查看器中的文档?
解决方案
使用:
function refresh() {
document.getElementById('viewerForm:viewer').contentDocument.location.reload();
}
<p:commandButton value="Load document" ... oncomplete="refresh()" />
代替
<p:commandButton` value="Load document" ... update="viewerForm:viewer" />
为我工作。
推荐阅读
- java - 为什么如此重复带有时间戳的罐子?如何避免它
- wordpress - 仅在存档中显示作者帖子的帖子(不包括 admin 和 editor )
- python - 从文本文件 Python 中读取 2 列
- spring-boot - Spring Boot Wildfly 无法与 eureka 一起使用
- python - 用于在之后替换 unicode 的正则表达式
- java - 迭代如何排序数组?
- multithreading - 多进程/线程编程属于哪些并发模型?
- python - 给出任何数字时如何获取列表的位置范围?
- google-apps-script - 如何从谷歌驱动器中的一个位置安全地删除多链接文档和文件夹?
- go - 方法调用与通道的使用