Sun. Oct 24th, 2021

Explanation: FacesMessage represents a single validation (or other) message, which is typically associated with a particular component in the view. A FacesMessage instance may be created based on a specific messageId. The specification defines the set of messageIds for which there must be FacesMessage instances.

FacesMessage is used to show confirmation, warning, information.

Requirement: I have a demo.jspx page. On that page I have a button with the name as Show ADF FacesMessage. Now, on click of the Show ADF FacesMessage button it show opens an ADF FacesMessage window displaying the message as “FacesMessage shown Successfully!

Screenshot of the above requirement is shown below:

Solution: For solution of the above requirement follow the steps as shown below:

Step 1: Create an ADF Fusion Web Application. Create a demo.jspx page. On that page have a button with the name as Show ADF FacesMessage.

Step 2: Create an actionListener with the name as showFacesMessage for the Show ADF FacesMessage button. The name of the bean is MyBean.java

Thus, the complete code for the demo.jspx is shown below:

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="" version="2.1" xmlns:f=""
          xmlns:af="">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document title="demo.jspx" id="d1">
            <af:form id="f1">
                <af:button text="Show ADF FacesMessage" id="b1" actionListener="#{MyBean.showFacesMessage}"/>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>

Step 3: Write the below code for the actionListener that is for the showFacesMessage method.

Thus, the complete code for MyBean.java is shown below:

package com.susanto;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

public class MyBean {
    public MyBean() {
    }

    public void showFacesMessage(ActionEvent actionEvent) {
        FacesMessage Message = new FacesMessage("FacesMessage shown Successfully!");
        Message.setSeverity(FacesMessage.SEVERITY_INFO);
        FacesContext fc = FacesContext.getCurrentInstance();
        fc.addMessage(null, Message);
    }
}

Save all and run the application. Thus, the ran application is shown below:

Now, click on the Show ADF FacesMessage button and we can see the FacesMessage as shown below:

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 626 total views,  4 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

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

satta king chart