Saturday, January 26, 2019

Search Form in Oracle Visual Builder based on ADF BC REST

Oracle Visual Builder supports ADF BC REST out of the box. Build service connection using "Define by Specification" wizard:

Wizards support ADF as API type. Add describe at the end of the REST URL, this will bring metadata for exposed ADF BC REST service (information about attribute types, etc.):

List of endpoints will be populated automatically. You could select all endpoints to be supported for your connection or select only few:

The most typical thing you would do with endpoint - map it with the table to display collection data. You would drag and drop Oracle JET table into VBCS page and choose Add Data option to map it with the service connection:

In the wizard you would select previously defined service connection:

There is a way to switch wizard to detailed view and choose from multiple endpoints available for the connection:

In the next step, you would select service attributes to be displayed in table columns. All declarative, sweet:

In Visual Builder at any point you can quickly test application, it will load in separate browser tab (or you could switch app to Live mode and test page functionality directly in VBCS window):

Every action in Visual Builder is handled through events. For example, this event is mapped with Reset button (you can see it in structure tab on the left):

At any point, you can switch to source view and check (or edit) HTML/JET code which is generated for you by Visual Builder. So cool, imagine typing and copy-pasting all this text by hand, tough and time-consuming (you could do better things in your life than copy-pasting HTML code):

Let's explain how search form logic is done in this sample. I have defined page scope variable type, this type would hold search attribute name, type and operation:

Create as many variables based on this type, as many search criteria items you will expect to have. Make sure to provide attribute and operation names (leave value property empty, this will be assigned by user):

Map search form fields with variables:

Create an event for Search button, which calls search action chain:

In action chain we can define search logic. Before executing search criteria, we need to prepare search criteria array (normally this step could be skipped, but there is issue in current Visual Builder, it fails to execute criteria search, when at least one of the criteria items empty). Calling custom JavaScript function where search criteria array will be prepared:

Custom JavaScript function, it helps to prepare array to be based to criteria (if search item is not set, we are assigning empty value):

Result of the function is mapped with service connection criteria, search will be executed automatically:

Table pagination is handled automatically too. Make sure to specify scroll policy = loadMoreOnScroll and define fetch size:


1. Sample source code on my GitHub
2. Blog from Shay - Filtering Data Providers with Compound Conditions in Visual Builder
3. Blog from Shay - Oracle JET UI on Top of Oracle ADF With Visual Builder
4. My previous post about query logic in Visual Builder - Query Logic Implementation in VBCS for ADF BC REST

No comments: