我像这样将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" />
为我工作。