Update Model Values while Validation (Exception) occurs on page on Value Change event- Oracle ADF (processUpdates)

Sharing is Caring

In ADF when we have some validation on the page and we try to submit any value, but normally after validation (Exception) values are not updated in Model until the exception is handled.
This tutorial is about how to update model values while exception on the page.
For a scenario, I have used department (default HR Schema) table and form in a JSP XML fragment inside the bounded task flow.
In form Department Id and Department Name is the mandatory field, ManagerId and Location Id has auto submit true.

  • I have dropped createInsert, Execute, Commit and Rollback as buttons on the page

  • Click on create button and first enter manager id, as this field has auto submit true so on submission of value, the page is validated and then Required Fields throw an exception, and after exception you can see that manager id & location id is not updated in Model, and not reflected in af:table also.
  •  Normally what we do, set immediate true to skip validations, but in this case, I have written ValueChangeListener on manager Id and Location Id to process values in Model.- see code
    public void mangrIdVCE(ValueChangeEvent vce) {
        vce.getComponent().processUpdates(FacesContext.getCurrentInstance());
    }

 

  • processUpdates() method of UIComponent class perform the component tree processing for all facet of this component by Update Model Values phase of request processing and pushes data to Model

 

  • Now after calling this method, run the application- Now values are populated in af:table and validation is still there on the page
Update Model
  • this approach can be used while using validators on the page and want to process some values after validation (as conditional validation of some fields etc)
  • Download sample ADF application –Download

Cheers 🙂 Happy Learning

Related Posts

Leave a Reply

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