如何使用 b:growl



我试图展示从bean加载的特定b:growl元素,基本上我试图复制BootsFaces展示(https://showcase.bootsfaces.net/forms/Growl.jsf;jsessionid=QdtXGdUxPK9sS714iLGuyksK93AMfZM-WfZm3py_.showcase01(中的示例。 我用过 FacesMessages.info,但我收到两条b:growl消息。那么,如何定位特定的 b:growl 元素来显示我的信息呢? 在展示的例子中:messagesBean.specificInfo 方法有什么作用?

编辑: 谢谢斯蒂芬,但对我不起作用,我仍然收到两条 b:grolw 消息,一个宽度 globalOnly="true" 被忽略,而是显示一个标准。

这是我的代码: .xhtml:

<ui:define name="content">
<div class="container" style="width: auto">
<h:form id="idForm">
<b:panel title="#{msg['administrarServicio']}" look="primary"
id="panel" collapsible="false">
<b:commandButton id="idBorrar" col-lg="3" col-md="3" colSm="10"
col-xs="10" offset-lg="2" offset-md="2" offset-sm="1"
offset-xs="1" value="Borrare o o o o" look="danger"
iconAwesome="trash" iconAlign="right"
action="#{serviceManagementBean.borrar}" />
</b:panel>
<b:growl id="growlCommonMsg" placementFrom="bottom"
show-detail="true" show-summary="true" allowDismiss="true"
global-only="true" delay="10000" escape="true" />
<b:growl for="idBorrar" id="growlMsg" globalOnly="true"
placementFrom="bottom" show-detail="true" show-summary="true"
allowDismiss="true" delay="10000" escape="true" global-only="false"
animation-enter="animated bounceInDown"
animation-exit="animated flipOutX" />
</h:form>
</div>
</ui:define>

爪哇岛:

public void borrar() {
System.out.println("BORRAR " + this.idTramite);
FacesMessages.info("idForm:idBorrar", "Se boró correctamente el servicio " + this.idTramite, "Nunca va a volver. ¡Nunca!");
}

让我们从您缺少的源代码开始。给你:

public void specificInfo() {
FacesMessages.info("growlForm:ref", "Info", "This is a specific message!");
}
public void error() {
FacesMessages.error("Error!", "Something has gone <strong>wrong</strong>.");
}

您会注意到唯一的区别是参数的数量。specificInfo()包括 IDgrowlForm:ref。您没有将其包含在代码片段中,但growlForm是周围表单的 id(至少在我们的展示中(。id的第二部分,ref,表示FacesMessage将由<h:message><b:message><p:message><p:growl><b:growl>显示,该在此形式中定义并带有属性for="ref"

查看展示柜的两个<b:growl>,您会发现第一个咆哮没有for属性。相反,它会设置globalOnly="true"。这会导致咆哮忽略每个带有 id 的面孔消息。它将忽略specificInfo()生成的消息。

这就是为什么我们的展示示例中有两个<b:growl>s,但每个用户操作只会触发其中一个。

有那个。你的问题是相反的:一个<b:growl>在屏幕上显示两个咆哮元素。你还没有提供任何Java源代码(还没有?(,所以我只能猜测。最可能的解释是,你真的生成了两次FacesMessage。我建议在调试器中设置断点(或添加 System.out.println((,如果您更喜欢这种方法(来排除这种情况。

我希望我已经给了你足够的线索来解决你的问题。如果没有,请随时通过我们在 GitHub 上的错误跟踪器与我们联系。请包含此StackOverflow问题的链接,以便我可以在必要时更新此答案。

相关内容

最新更新