In one of my project, I had a requirement to add & remove af:messages from input components. In this post, I will show the javascript code used to achieve it.
For adding af:message to an input component using java script, use the following code.
For removing af:message from an input component using java script, use the following code.
For adding af:message to an input component using java script, use the following code.
function customJSMethod(evt){
var source = evt.getSource();
var inputComponent = source.findComponent('inputcompId’);
var message = “Valiation Failing…”;...//Custom message to be added on component.
AdfPage.PAGE.addMessage(inputComponent.getClientId(), new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR, null, message));
AdfPage.PAGE.showMessages(inputComponent.getClientId());
}
For removing af:message from an input component using java script, use the following code.
function customJSMethod(evt){
var source = evt.getSource();
var inputComponent = source.findComponent('inputcompId’);....
AdfPage.PAGE. clearMessages (inputComponent.getClientId());
AdfPage.PAGE.showMessages(null);
}