ADF Basics: Show Faces Message in Oracle ADF

Sharing is Caring

FacesMessage is used to show confirmation, warning, information. In this tutorial, you will see that how to use Faces Message to show any information, warning or any error. Suppose you want to show a confirmation when you save your records, here we use Faces Message.

Managed Bean Code to use Faces Message(Information)-

      FacesMessage Message = new FacesMessage("Record Saved Successfully!");   
      Message.setSeverity(FacesMessage.SEVERITY_INFO);   
      FacesContext fc = FacesContext.getCurrentInstance();   
      fc.addMessage(null, Message);   

To use for Error and Warning just change FacesMessage.SEVERITY_INFO to SEVERITY_ERROR or SEVERITY_WARN.
It will look like this

Faces Message in Oracle ADF

You can change your Message accordingly

 

Related Posts

An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF

5 thoughts on “ADF Basics: Show Faces Message in Oracle ADF”

  1. How to show similar functionality in 12c. I’m using JDev 12.2.1.3.0 version and suggested code is not working and throws NPE.
    Please suggest how to implement in latest version instead of 11g.

      1. No, there is no error or exception in the log file.

        I have submit button in the login page and the user clicks without username/password then suggested code working fine in 11g bu displaying error alert message whereas in 12g latest version, getting NPE.

        user.jspx

        LoginBean.java class
        public String loginAction() {
        String status = “failure”;
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ResourceBundle bundle = ResourceBundle.getBundle(VALIDATION_RESOURCE, facesContext.getViewRoot().getLocale());
        //Login failed, set error message
        facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR, errorMsg, “”));
        return status
        }

          1. No, its getting NPE after return statement where I don’t have any control. How to handle in the jspx page?

Leave a Reply

Your email address will not be published. Required fields are marked *