Я работаю с Prime Faces
, и я хотел бы, чтобы пользователь начинал на индексной странице, нажимал кнопку для вызова функции (registrarUsuario
) для перезагрузки индексной страницы и отображения контекстного сообщения. Моя проблема заключается в том, что мое приложение не отображает сообщение. Это мой код:Почему в моем приложении JSF не отображается контекстное сообщение?
index.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:b="http://bootsfaces.net/ui">
...
<h:form>
<b:commandButton action = "#{registroUsuario.registrarUsuario}" value = "call function"/>
</h:form>
....
RegistroUsuario.java:
public void registrarUsuario() throws IOException, Exception {
try {
//another code
FacesMessage message = new FacesMessage(":D", "message");
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, message);
} catch (Exception e) {
FacesMessage message = new FacesMessage("Falla", e.toString());
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, message);
}finally{
FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml");
}
}
Спасибо!