2016-11-18 59 views
0

首先,你应该知道我是使用jsf开发web应用程序的新手,所以如果我要求不好的东西,请纠正我。使用p:media或p:documentViewer with p:dialog dynamic

我需要开发一个表格,显示一个PDF文件的描述和一个按钮,将其显示在对话框中(重要的是不应该能够下载,复制或打印此文件)。我用尽我所有的各种可能性和,但显示该对话框时,不显示文件,这是我的代码:

<h:body> <ui:composition template="/template/plantilla.xhtml"> <ui:define name="content"> 
     <h:form id="frmpdf"> 
      <div align="center"><h:outputText value="Docs .PDF" style="font-weight: bold;"/> 
      </div> <p:dataTable id="dtdpdf" 
         var="dpdf" 
        value="#{documentosPdfBean.listdocpdf}" > 

       <p:column headerText="Descrip" style="width: 90%;"> 
        <h:outputText value="#{dpdf.sgTfd_descripcion}" /> 
       </p:column> 
       <p:column headerText="Open"> 
       <p:commandButton value="open" 
            oncomplete="PF('dlg3').show();" 
            update="frmpdf:dlgpdf" /> 
       </p:column> 
      </p:dataTable> <p:dialog id="dlgpdf" header="document" widgetVar="dlg3"    showEffect="explode" height="100" dynamic="true"> 
       <p:media value="/resources/document/manual.pdf" width="100%" height="300px"/> 
        </p:dialog>       
       </h:form> 
      </ui:define> 
     </ui:composition>    
    </h:body> 

我也用:

<p:commandLink title="manual" onclick="PF('dlg3').show()" /> 

result

以上开发考虑到了这个post

回答

0

在做了更多的研究后,我设法解决了我的问题,标签 ,允许从时触发此事件的豆树立的价值,我离开了代码的解决方案:

<f:view> 

<h:head> 
    <title>Page</title> 
    <script type="text/javascript" src="/js/keyboard.js" charset="UTF-8"></script>  
    <link rel="stylesheet" type="/text/css" href="/js/keyboard.css" /> 
</h:head>  

<h:body> 
    <ui:composition template="/template/plantilla.xhtml"> 
     <ui:define name="content"> 
      <h:form id="frmpdf"> 
       <f:event listener="#{documentPdfBean.onPrerender}" type="preRenderView" /> 
       <div align="center"> 
        <h:outputText value="Docs. PDF" style="font-weight: bold;" /> 
       </div> 
       <p:dataTable id="dtdpdf" var="dpdf" value="#{documentPdfBean.listdocpdf}" > 
        <p:column headerText="Descrip" style="width: 90%;"> 
         <h:outputText value="#{dpdf.sgTfd_descripcion}" /> 
        </p:column> 
        <p:column headerText="open"> 
         <p:commandLink styleClass="fa fa-file-pdf-o" onclick="PF('dlgpdf').show()" 
             update="frmpdf:pdfvisualizer" style="width: 10px; font-size: 20px; margin-left: 24%;"> 
          <f:setPropertyActionListener target="#{documentPdfBean.ruta}" value="#{dpdf.sgTfd_valor}" /> 
         </p:commandLink> 
        </p:column>        
       </p:dataTable>                 
       <p:dialog widgetVar="dlgpdf" height="700" width="750" header="pdf" maximizable="true" minimizable="true" 
          resizable="false" dynamic="true" showEffect="clip"> 
        <pe:documentViewer height="700" id="pdfvisualizer" value="#{documentPdfBean.ruta}" /> 
       </p:dialog> 
      </h:form> 
     </ui:define> 
    </ui:composition>    
</h:body> </f:view> 

private String ruta; 

public String getRuta() { 
    return ruta; 
} 

public void setRuta(String ruta) { 
    this.ruta = ruta; 
}