Skip to main content

Clearing the stale messages from the previous request on client side validation error

While going through a specific use case, I came to know that ADF Faces run time does not auto clear the messages added to the page from the previous request. This indeed is the expected behavior as of now. I'm sure many of you know this already, however thought of posting this for the benefit of developers who has not worked on such scenarios before, like me;).

The side effect of this implementation is that, once you displayed any message to the end user by adding a FeacesMessage to a FacesConetxt from an event handler method and if the next immediadte action from the end user result in anay client side validation error, you may get the previous message and the newly generated validation error in the message window as shown in the following screen shot.

Let me discuss a work around solution for such use cases. Its simple, add a af:clientListener to the UI component to clear the messages by calling ADF Fcaes JavaScript API AdfPage.PAGE.clearMessages(componentId);.
 <af:commandButton text="Save with Clearing Prev Message"   
      id="cb2" actionListener="#{TestBean.saveAction}"  
      <af:clientListener method="clearGlobalMessage" type="click"/>  
 <af:resource type="javascript">  
  function clearGlobalMessage() {  


I'm attaching a very simple example illustrating the above solution. You can download the sample workspace from here.
[Built using Oracle JDeveloper]

How to run this sample?

Run test.jspx, key in some values in the input field and click save button. You may see information message. If you click save button again, validation error message alone appears.The previous INFO message is cleared using javascript method clearGlobalMessage()

Please note that, the above case will be addressed in future releases in a much better way. In fact there is an enhancement request for the same, be happy :)


Anonymous said…

Is there a way to customize the default validation popup?
Like, remove the hyperlink for the mandatory fields, etc.?


Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!