打开对话框PrimeFaces wihout的commandButton
问题描述:
我在我的应用程序定义此链接:打开对话框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页面中,但我需要对话窗口。你能帮我么?谢谢。
答
您不需要在链接上使用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尝试使用,而不是dlg2
dlg1
的widgetVar
这是什么对话了。
您可以使用'
'' – Holger