In my Xpages application I am using Bootstrap for theming. I have a xp:messages box that I have applied some Bootstrap CSS to.
When then are no messages I want to hide the panel that contains the messages. So I came up with the following:
<xp:panel rendered="#{javascript:facesContext.getMessages().hasNext()}" styleClass="alert alert-info">
<xp:text escape="true" value="#{javascript:facesContext.getMessages().hasNext()}">
</xp:text>
<xp:messages globalOnly="true" layout="list"></xp:messages>
</xp:panel>
However I notice sometimes the xp:messages control is empty but facesContext.getMessages().hasNext() returns true.
Is there another way to check the value of xp:messages? I tried getComponent(...).getValue() but than the application breaks.
This is what is returned to the browser:
<div class="alert alert-info">
<span>true</span><span role="alert"></span></div>
have you tried to directly apply the bootstrap class to the xp:messages control? e.g.
<xp:messages id="messages1" infoClass="alert alert-info"></xp:messages>
hereby you do not need the surrounding panel and compute the rendered property