Requirement: I have a button with the name “Show Inline FacesMessage” on the ADF Page. Once the user clicks on the “Show Inline FacesMessage” button it should display an inline message as shown below:
Solution: For solution of the above requirement follow the steps as shown below:
Step 1: Create an Oracle ADF Fusion Web Application.
Create demo.jspx page inside the ViewController project.
Step 2: Drag and drop an af:button and text=”Show Inline FacesMessage”
Also set actionListener=”#{pageFlowScope.MyBean.showInlineMessageActionListener}”
Thus, the code for the demo.jspx page is as 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 Inline FacesMessage" id="b1" actionListener="#{pageFlowScope.MyBean.showInlineMessageActionListener}"/> </af:form> </af:document> </f:view> </jsp:root>
And the complete code in the MyBean.java class is as below:
package susantotech.com; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; public class MyBean { public MyBean() { } public void showInlineMessageActionListener(ActionEvent actionEvent) { FacesMessage msg = new FacesMessage("This is an inline FacesMessage"); msg.setSeverity(FacesMessage.SEVERITY_FATAL); FacesContext fctx = FacesContext.getCurrentInstance(); fctx.addMessage(null, msg); } }
Save all and run the application. Thus, the ran application is shown below:
Click on “Show Inline FacesMessage” button and we can see the message as below.
In the above output the message is displayed inside a dialog as a Faces Message. But my requirement is to display the message inline with the “Show Inline FacesMessage” button.
Hence, for that we have to do few addition changes.
So, let us drag and drop af:messages component in the demo.jspx page just after the “Show Inline FacesMessage” button.
Set the inline property as true
Thus, the modified code for the demo.jspx page is as 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 Inline FacesMessage" id="b1" actionListener="#{pageFlowScope.MyBean.showInlineMessageActionListener}"/> <af:messages id="m1" inline="true"/> </af:form> </af:document> </f:view> </jsp:root>
Save all and run the application. Thus, the ran application is shown below:
Click on “Show Inline FacesMessage” button and we can see the message as below.
Hence, the solution to the error.
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
366 total views, 1 views today