Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Search Form in Oracle Visual Builder Based on ADF BC REST

DZone's Guide to

Search Form in Oracle Visual Builder Based on ADF BC REST

Oracle Visual Builder makes it easy to create microservice applications out of the box. Read on to learn how to make a search function!

Free Resource

Record growth in microservices is disrupting the operational landscape. Read the Global Microservices Trends report to learn more.

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

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

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

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

In the wizard you would select the 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 the application. It will load in a separate browser tab (or you could switch the ap to Live mode and test the page functionality directly in the VBCS window):

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

At any point, you can switch to source view and check (or edit) the 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 the page scope variable type; this type would hold the search attribute name, type, and operation:

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

Map search form fields with variables:

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

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

Here's the custom JavaScript function. It helps to prepare the array to be based to criteria (if the search item is not set, we are assigning an empty value):

The result of the function is mapped with the service connection criteria. The search will be executed automatically:

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

Resources:

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

Learn why microservices are breaking traditional APM tools that were built for monoliths.

Topics:
microservices ,microservices tutorial ,application development

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}