ADF, Continuous Query Notification, JDeveloper

Override inputListOfValues component model and Continuous Query Notification sample in ADF

Requirement:

Standard ADF inputListOfValues component should behave like this:

    • When pressed “Search”, action should stop and wait untill any change happen in DB table being searched
    • When change happen in DB table, search should resume among updated data. If no change happen it should resume after 10 seconds timeout
    • In addition – search input field validation should happen on “Search” press. If there is no at least one field filled with at least 3 symbols – error should be shown.
Well, this requirement may look sensless, but this is just a PoC of functionality, of what and how is possible to implement. Maybe a peace or a whole of this sample can be adapted to your case.
Solution:
  • Create a separate class which extends ListOfValuesModel, put custom logic there for validation and processing query
  • Use Continuous Query Notification (CQN) or in earlier Java releases called Database Change Notification (DCN) for delivering event from DB to application
  • Use Java latches (CountDownLatc) for suspending and resuming search after either an event from DB or timeout occurs.
This PoC will use Oracle DB and HR schema for sample data. Will put LOV on departmentId attribute of EMPLOYEES table. Will suspend searching in DEPARTMENTS table untill any change there happens.
  • Lets start from creating custom class for inputListOfValues model:
  • Configure LOV for departmentId in EmployeesView. Set UI hint for list type “Input Text With List of Values”. Create main.jspx file and drag’n’drop EmpoyeesView data control into it, render as regular ADF table. Check whether inputListOfValues component is rendered for departmentId attribute:
  • Create a managed bean mainBean.java for main.jspx and put there getter of inputListOfValues model. Reassign model in main.jspx.
  • Get back to custom model class ListOfValuesModelEx. Put necessary validation and change subscribtion logic into method performQuery. Special attention to CountDownLatch utility here – it is used to suspend query execution and wait either till it is notified from the CQN listener or timeout occurs. The key points are emphasized in red:

For more detailed sample description of Continuous Query Notification (CQN/DCN) usage, please have a glimpse to my previous post: WebSocket together with DB Change Notification in ADF for immediate data refresh in browser (complete sample).

Thats it,  please download sample application to find more details and test it!
 
JDeveloper version 12.1.0.0