Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Saturday, August 15, 2009

Programmatic error message in ADF 11g

There are situations when you may need to show error messages from your managed bean code to your ADF page.

ADF 11g supports two level of messages as component level messages and page level messages.

To show a component level message write the following code in your managed bean method:

FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "this is component level message");
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(.getClientId(context), msg);

Also note that you need to add component to your page (anywhere).

To show page level message you need to use following code:

FacesContext context = FacesContext.getCurrentInstance();
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Value entered is invalid");
context.addMessage(null, msg);

1 comment:

Anonymous said...

Nice Post. This record helped me in my school assignment. Thanks Alot