2017-10-09 81 views
0

我在我的應用程序定義此鏈接:打開對話框PrimeFaces wihout的commandButton

<a href="${request.contextPath}/pages/help/applicationHelpVersion.jsf" title="#{msg['menu.version']}" onclick="window.open(this.href, 'applicationHelpVersion','left=20,top=20,width=400,height=300,toolbar=0,resizable=1'); return false;">#{msg['menu.version']}</a> 

該解決方案將打開當前的應用版本號新的瀏覽器窗口。

我想重新定義它,以便新的對話窗口打開。

我使用primefaces,並有模態對話框我想使用,但它與所有示例中的commandButton相結合。

這裏是applicationHelpVersion.xhtml:

<ui:composition 
     xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:ui="http://java.sun.com/jsf/facelets" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:f="http://java.sun.com/jsf/core" 
     xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:hr="http://java.sun.com/jsf/html" 

     template="/layout/helpLayout.xhtml"> 


    <ui:define name="insert-application-content"> 
     <div style="text-align:center"> 
      <h1><h:outputText value="version: "/><span class="applicationVersionContent">${versionContext.productVersion}</span></h1> 
      <!--<h1><h:outputText value="stage: "/><span class="applicationVersionContent">${versionContext.productNameExtension}</span></h1>--> 
     </div> 
    </ui:define> 
</ui:composition> 

能否請你幫我如何打開新的模態對話框與應用程序的版本?我試過這樣的事情:

<a href="${request.contextPath}/pages/help/applicationHelpVersion.jsf" title="#{msg['menu.version']}" onclick="PF('dlg1').show();">return false;">#{msg['menu.version']}</a> 

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100"> 
    <h:outputText value="here will be version of app..."/> 
</p:dialog> 

我真的不知道在這裏設置href參數或者如果可以這樣做。在此狀態下,應用程序版本將顯示在新的.jsf頁面中,但我需要對話窗口。你能幫我麼?謝謝。

+0

您可以使用''' – Holger

回答

0

您不需要在鏈接上使用href屬性,因爲您實際上並未鏈接到其他頁面。使用的onclick的鏈接的使用Primefaces' javascript庫這樣打開對話框:

<a onclick="PF('versionDialog').show();">My link text</a> 
<p:dialog widgetVar="versionDialog"> 
    <h:outputText value="#{elToGetVersionInfo}" /> 
</p:dialog> 

有了這個例子,你的鏈接文本將不會被造型像一個超級鏈接,因爲沒有href屬性。如果您希望文字的樣式像鏈接一樣,請在錨標記上使用href="#"

你在你的問題的底部例子是接近,但你的onclick嘗試使用,而不是dlg2dlg1widgetVar這是什麼對話了。