Posts

Featured Post

SPA with JDeveloper and WebLogic

JDev: 12.2.1.4.0
Source: GitHub

This article steps out the key requirements of deploying a single-page-application on WebLogic server. Essentially, there are just three important gotchas in this process, which I will lay out in detail.

The SPA, in this use-case, is an Angular 8 application. I have put the source code as part of the JDev application.


I have customised the build process of the Angular application to generate the artifacts inside the public_html folder of the RESTWebService project. You may go with the usual build directory and then manually copy the generated files into the public_html folder.


Gotcha # 1:
The SPA should be built with the html file having a base-href property same as the context-root of the JDev application.



Gotcha # 2:
If you are using routing in your Angular application (you will obviously), then you will usually keep a component to display in case there is no route match (the wildcard ** path). In this case, the Angular routing handles the 404 page-not…

Tab Index with PanelFormLayout

Image
JDev: 12.1.3.0.0
Source: GitHub

This article talks about an interesting use case of JavaScript in ADF faces - the tab index.

By default when we use a panel-form-layout in ADF faces, the default behaviour of the cursor on tab is to go the next element as defined inside your panel-form-layout xml metadata.

So for a layout with 4 rows and 2 columns, the default cursor travel behaviour is something like this:


But what if I need a traverse pattern like this:


One not-so-simple and tedious way would be to to rearrange the items inside the form-layout. But for a large and complex form that is not an ideal option, and obviously that is not the solution I am planning to provide.

A simpler alternative would be to write a small JavaScript client-listener method, which would take 2 arguments - the previous item and the next item - and depending on these 2 values, it would find the item to focus on. The previous element option would be used when the user wants to go in the reverse direction with S…

ADF BC REST service - Batch Processing

Image
JDev: 12.2.1.3.0
Source: GitHub

ADF BC REST services provide us with an interesting tool for bulk data processing - the batch process. The following article demonstrates how this feature can be quite helpful in reducing the volume of our code, and making our DML operations smooth.

As the name suggests, batch processing allows you to perform multiple DML operations in a single web service call.

A batch process is sent as a POST request, but there are 3 important ways a batch process differs from a standard POST request:

1) The base URL only goes till the rest URL pattern or the REST version.
2) The content-type header is "application/vnd.oracle.adf.batch+json".
3) Each DML operation in the batch is identified by a unique ID and an operation name ("create", "update" and "delete"). It is this ID which is referred to by the framework while reporting an error.


The body of the POST operation consists of an array of objects of the following structure:


View Object attribute source order

Image
JDev: 12.1.3.0.0
Source: GitHub

This article talks about the source order of ADF View Object's attributes and how it affects findByKey operation.

As a handy list, we need to remember that there are 3 items which need to be in sync in order for findByKey to work (or for that matter anything to work):

1. Sequence of columns in the ViewObject's SQL.
2. Sequence of attributes in the ViewObject's Attributes tab.
3. Sequence of attributes in ViewRowImpl's AttributesEnum.

Let's see how we can manipulate these orders and destroy our code! In order to demonstrate our use cases, I have a table VIEW_OBJECT_SOURCE_DEMO, which has 2 columns - KEY_ATTR1 and KEY_ATTR2 - which are marked as key attributes. In my AppModuleImpl class, I have a findByKey operation which takes in these 2 string values and returns a single row.

Let's go through the above 3 point list and see where we stand.


My AppModule's method is as follows:


Now if I run this method from BC tester, it works …

Get current row from ADF UI attribute

Image
JDev: 12.2.1.3.0
Source: GitHub

This is a quick blog post which showcases the power of ADF UI components' attribute. Alternatively, this blog post could also have had a heading of "Getting current row when af-table's row selection is disabled", but I randomly chose the former.

A typical use-case for such a requirement could be that the customer does not want any row selection, in order to improve the page performance, as every row selection change calls for a server trip wherein lot of information gets stored on the ADF framework.

But we also need a mechanism where, if an editable attribute of the ADF table is modified, we should be able to extract the row on which the operation was performed. Since row selection is disabled, the framework has no information of current row.

Here is where we can make use of <f:attribute>. We create a new attribute on the editable column, which holds "#{row}" value. This row expression comes from var attribute of the A…

ADF BC REST service - Type Mapping

Image
JDev: 12.2.1.3.0
This article talks about a powerful, yet under-utilized, feature of ADF BC - the data type mapping. Oracle ADF provides this feature to generate a runtime mapping between a View Object's String attribute and a Web Service's (both SOAP and REST) Boolean attribute.
The most popular use-case for this feature is to map a Boolean Active/Inactive flag from the service to a Yes/No value on the View Object. By default, ADF provides 3 mappings, which cover the following scenarios:
1. oracle.jbo.valuemaps.BooleanYNPropertySet - maps Y/N to true/false. 2. oracle.jbo.valuemaps.BooleanTFPropertySet - maps T/F to true/false. 3. oracle.jbo.valuemaps.Boolean10PropertySet - maps 1/0 to true/false.
These property sets are in adfm.jar, which is part of the ADF Model Runtime library.
The advantage of using a type mapping is a two-way binding - you may pass the String as well as the Boolean value in the payload, and the type mapper automatically translates to the required value t…

ADF BC REST service - Attachments

Image
JDev: 12.2.1.3.0
Source: 1) ADF BC REST, 2) Oracle JET application

Continuting on the previous discussion on ADF BC REST - Type Mapping - the framework can be stretched further to work with uploading files and images. Working with attachments is an important aspect in any commercial application; and ADF BC REST service provides us with a robust mechanism to store and display files and images through BLOB columns.

The following article discusses both about developing the REST service for storing documents in an Oracle database, as well as configuring an Oracle JET application which uploads and displays an image on the GUI.



The REST API I have added a PROFILE_IMAGE column of BLOB type to the employees table in the HR schema, and I will use this column for storing my attachments. BLOB columns are handled in a slightly different way by the REST API. The BLOB column is not included in the actual payload, but it comes as part of the links section, as an enclosure attribute.


The href value c…

ADF BC REST service - defaulting with CREATE method

Image
JDev: 12.2.1.3.0

This is more like an update on my previous article - ADF BC REST - NULL and DEFAULT, where I spoke about the various ways null data can be defaulted via a REST API. However, there was one use case which I had missed - the CREATE method of EntityImpl.

There is an interesting behaviour which may be observed when, instead of  setting a default value declaratively on the entity attribute, we override the CREATE method of the EntityImpl subclass.

When a value is set in the create method, this value takes precedence, irrespective of whether we pass null, some value or don't pass the attribute in the payload at all.

To demonstrate this, I will set a value of 25000 for Salary attribute in the create method.


And I will pass the below payloads:


For all the three payloads, the data gets saved with salary 25000, the value with which it was initialized in the create method, irrespective of the fact that I also have a declarative default value for the Salary entity attribute.


ADF BC REST service - NULL and DEFAULT

Image
JDev: 12.2.1.3.0 Source: GitHub
This article talks about an interesting difference between passing null and no value for a column in the payload of an ADF BC REST end-point. Now this might seem a bit obvious in the end, but nonetheless, it can be confusing at times.
To demonstrate this problem, I have the following use-case: Set a default value for employee "Salary" during insert or update!
Now your GUI might have some required validation set on this field, and it does not allow the end-user to save the form without a non-zero salary. That is all good. But your QA might have an automation running to check the REST APIs with their own payload. And this is something which needs to be in sync with the UI logic.
To get started, I have my Employee entity object with a default value of 5500 for Salary field.

Case # 1: Payload does not contain Salary attribute

When I submit this payload, I get back an Employee object with the default Salary of 5500, as declaratively set up on the e…