February 6, 2013

How to display a message dialog on the JSF page



The below code will be used to display a message dialog on the JSF page.

        FacesContext facesContext = FacesContext.getCurrentInstance();
        FacesMessage facesMessage = new FacesMessage(message);
        facesMessage.setSeverity(severity);
        facesContext.addMessage(null, facesMessage);

Where message is the message what we want to display on the dialog box and severity is to show the severity of the message. Example for severity is FacesMessage.SEVERITY_INFO which displays the dialog box as an information message. Inputs for severity is available in FacesMessage class.

No comments:

Post a Comment