I am trying to display simple messages with <p:messages/>
but only I've got is the message of development mode of MyFaces. I will explain.
On my XHTML page, I have the following code to diplay my messages:
<div class="messagePanel">
<p:messages id="msgCalls"
for="msgCalls"
showDetail="true"
showSummary="true"
autoUpdate="true"
closable="true" />
</div>
On my bean:
@PostConstruct
public void init() {
try {
this.linhaCelularId = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("linhaCelularId");
if (this.linhaCelularId == null || this.linhaCelularId.trim().isEmpty()) {
Messages.addGlobalError(MENSAGEM_GLOBAL, "Nenhum celular especificado para listagem de ligações");
}
else {
this.linhaCelularTitular = getLinhaCelularTitularService().getById(Long.parseLong(this.linhaCelularId));
if (this.linhaCelularTitular == null) {
Messages.addGlobalError(MENSAGEM_GLOBAL, "Celular não encontrado!");
}
else if (!this.linhaCelularTitular.getResponsavel().getAn8().equals(this.loginMB.getLoggedUser().getAn8())) {
Messages.addGlobalError(MENSAGEM_GLOBAL, "Você não tem permissão para acessar essa página. Esse erro foi reportado.");
}
else {
this.faturaTitular = getFaturaTitularService().getUltimaFaturaCarregada();
this.itensFaturaTitular = getFaturaTitularService().getItensFaturaPorCelularFatura(this.linhaCelularTitular, this.faturaTitular);
}
}
}
catch (ServiceException e) {
logger.error("Erro ao buscar ultima fatura carregada", e);
throw new RuntimeException(e);
}
}
The problem is, that the message added by Faces.addGlobalError()
or Faces.addError()
is not showing by my <p:messages.../>
. The message only shows up on Unhandled Messages of development mode. Take a look when I inspect the HTML:
<ul id="javax_faces_developmentstage_messages"
title="Project Stage[Development]: Unhandled Messages"
style="color:orange">
<li>
<span title="Project Stage[Development]: Unhandled Messages">Você não tem permissão para acessar essa página. Esse erro foi reportado.</span>
</li>
</ul>
I already tried some other ways to do:
- Put only
<p:messages/>
and <h:messages>
on XHTML;
- Tried to use
Faces.addGlobalError()
and Faces.addError()
;
- Used
FacesMessage message = new FacesMessage();
None of above worked. I don't know what else to do. Currently, I am using MyFaces 2.1.12, Primefaces 4.0 and Omnifaces 1.5.