I'm trying to make a simple dialog alert for when a user tries to delete something. But my problem is with PrimeFaces. The response content is as expected a 500 error with the message I want to show but it doesn't show the message, the dialog appear and is empty.
Here is my the code of my backing bean:
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error!", "No se ha podido eliminar el periodo"));
ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response = (HttpServletResponse) context.getResponse();
response.setStatus(500);
Here is the command button:
<p:commandButton value="Eliminar"
action="#{cicloEscolarWiz.doConfirmarEliminarPeriodoLectivo}"
ajax="true"
onerror="messages.show();"
update=":dlgMessages"/>
And here is my dialog:
<p:dialog id="dlgMessages"
showEffect="explode"
closable="true"
header="Mensajes"
widgetVar="messages"
modal="true"
style="font-size: 12px;">
<h:panelGroup id="pnlGrpMessages">
<p:panel>
<h:panelGrid columns="1" cellpadding="0" cellspacing="0">
<p:messages id="deletePeriodoLectivoMessages"
showDetail="true"
autoUpdate="true"
closable="true" />
</h:panelGrid>
</p:panel>
<p:spacer height="10"/>
<p:separator />
</h:panelGroup>
</p:dialog>
So what I want to achieve is when I hit the command button make a response of a 500 error then the dialog must appear and appears but empty, there's no message.