【问题标题】:use p:media or p:documentViewer with p:dialog dynamic使用 p:media 或 p:documentViewer 与 p:dialog 动态
【发布时间】:2017-04-02 14:34:49
【问题描述】:

首先你应该知道我是使用 jsf 开发 web 应用程序的新手,所以如果我要求不好的地方,请纠正我。

我需要开发一个显示pdf文件描述的表格和一个在对话框中显示它的按钮,(重要的是不能下载、复制或打印这个文件)。我用 and 用尽了所有的可能性,但是在显示对话框时,没有显示文档,这是我的代码:

<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

【问题讨论】:

    标签: jsf primefaces dialog mediaelement.js commandbutton


    【解决方案1】:

    经过更多研究,我设法解决了我的标签问题 允许在触发此事件时从 bean 建立一个值,我将代码留给解决方案:

    <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;
    }
    

    【讨论】:

      最近更新 更多