Nazar Sobchuk
Nazar Sobchuk

Reputation: 297

JSF error page message

I have a project, written on JSF. Now I need to display an error message on my error page. At the moment I display them like this:

<h:outputText id="errormsg" value="#{requestScope['javax.servlet.error.message']}"/>

and get not only the error message, but also an error class itself, like this:

com.bar.foo.IncorrectPasswordException: "Incorrect password!"

How can I display only the error message itself? Thanks

Upvotes: 1

Views: 387

Answers (1)

Aritz
Aritz

Reputation: 31651

Use <h:messages>, as it is the default message handler for JSF. Look at this link. Then you can use the API for adding messages to FacesContext:

FacesContext.getCurrentInstance()
  .addMessage(new FacesMessage(null, FacesMessage.SEVERITY_ERROR, yourMessage));

And you'll get them printed by the <h:messages> tag.

Upvotes: 1

Related Questions