Tuesday, June 7, 2016

Oracle JET Executing Dynamic ADF BC REST URL

I'm going to explain how to call ADF BC REST service from JET API and how to control parameters passed through to REST URL. Most of the time, REST should return data based on different parameter values, URL is not static. I will be exploring two cases - search functionality, where parameter value is entered by the user and LOV functionality, where current employee key is submitted to fetch colleagues list.

You can go through the slides from my AMIS25 session - Oracle JET CRUD and ADF BC REST. I explain similar concepts:

Download sample application (you must run ADF BC REST application in JDEV 12.2.1 and JET in NetBeans 8) - JETCRUDApp_v9.zip.

1. Filter implementation

We should take a look first, how filter/search functionality is implemented. User enters keyword for Last Name and filters data in JET table:

User can reset search results, change filter criteria. Filtering is done using startswith operator, by ADF BC VO (it creates temporary bind variable from REST URL parameter q=LastName LIKE value):

Filter block is implemented in a separate HTML div. Filter value is mapped with observable variable registered in JET View Model:

Table collection is based on collection with dynamic REST URL. URL is calculated through customURL property (referencing JavaScript method) in the collection. On filter event, we clear up all dependent data and call JET collection API method - refresh(). This ensures reload for collection and REST URL re-calculation. Similar is done on reset:

Method getURL is responsible to read filter value and construct REST URL accordingly (this will be used to re-fetch collection content):

Here you can see generated REST request URL logged by NetBeans Network Monitor. This URL contains filter information supplied through dynamic REST URL defined for the collection:

2. LOV data fetch implementation

There is LOV in ADF BC, which returns current employee colleagues (employees from the same job, except employee himself). ADF BC REST encapsulates parameters complexity and allows to simplify REST request. JET UI renders LOV data in a chart:

Each time when employee record is selected, we execute dynamic REST call (with new employee ID) to fetch colleagues collection:

This is chart definition in JET UI, it references observable variables for series/groups from JET View Model:

Similar as in the case with Filter, we supply dynamic URL for the collection, using property customURL:

Differently than in the Filter implementation, here we dont refresh collection. We execute JET API method fetch(...), to retrieve new collection and we push contents into observable variables, referenced by chart component in the UI:


Lucas Jellema said...

Thanks for this extensieve and very clear description. Well done, Andrejus! And thanks once more for your contribution to the AMIS25 Beyond the Horizon conference.

warm regards,


Andrejus Baranovskis said...

Thanks for great feedback, Lucas. This is really encouraging. I enjoyed AMIS25 ! You should organize something similar next year.