简体   繁体   English

在JSF中单击按钮时,在IFrame中显示PDF

[英]Display PDF in IFrame when button is clicked in JSF

I already coded one but it opens a new tab, what I want is to display the pdf inside the Iframe (the same page where the user inputted the data) when a command button is clicked. 我已经编写了一个代码,但是它打开了一个新标签,我想要的是单击命令按钮时在Iframe(用户输入数据的同一页面)中显示pdf。 Thanks for the help! 谢谢您的帮助!

You can use the rendered attribute to render content conditionally. 您可以使用rendered属性有条件地渲染内容。

Eg 例如

<h:commandButton value="Show PDF" action="#{bean.showPdf}" />
<h:panelGroup rendered="#{not empty bean.pdfUrl}">
    <iframe src="#{bean.pdfUrl}"></iframe>
</h:panelGroup>

with

public void showPdf() {
    pdfUrl = "/context/filename.pdf";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM