Sunday, November 8, 2015

Oracle JET - Rendering Table from ADF BC REST Service

Oracle JET - new tool for us to build UI applications with JavaScript. Right now there is no out of the box integration with ADF Faces, I heard on OOW there might be some sort of integration available in the future. At the end of the day this is only JavaScript and you can integrate it into existing ADF page by yourself. Probably you would not want this, ADF Faces offers very rich set of functionalities and there is no need in extra components. Unless you would like to use WebSockets in ADF and would like to push data from JavaScript into DVT components - it could be easier to do this with JET, instead of going through ADF Bindings layer.

JET comes with developer guide, this is the first source of information along with Cookbook examples. I have implemented sample application for today post, based on developer guide section - Creating a CRUD Application Using Oracle JET. Here you can download the sample - If you would like to run it, make sure to add JET JavaScript libraries, you can take them from JET QuickStart. Size of these libraries was too large, this is why I have removed them.

REST service is implemented with ADF BC, I have described it in previous post - ADF 12.2.1 ADF BC Support for REST.

This is how it looks a table rendered with JET from REST data supplied by ADF BC, with pagination support. JET is using Alta UI style, visually there is no much difference comparing to ADF Faces:

Data is displayed from REST generated on top of ADF BC:

Typical JET use case is implemented by combination of JavaScript and HTML files:

JavaScript function contains a logic to invoke and parse REST service, everything is handled by JET API and popular JavaScript modules (such as Knockout, etc.). You can see how REST resource URL is defined and there is parsing rule to apply to the fetch result. I have set to fetch up to 20 rows only:

There is main JavaScript file in JET. You need to include initialisation steps there:

The last step - UI. JET offers table component with pagination support. Pagination happens on client side, this means you should not fetch many rows anyway. UI structure is pretty simple:

I have recorded a video to show how table pagination works. All rows are on client side and still pagination is not super quick, as I would expect it:

For comparison, I have uploaded table pagination performance video for ADF 12c Alta UI. ADF Faces pagination support works pretty quick, if not faster:

I'm happy to have additional Oracle development toolkit available. We are going to use it in our projects in combination with ADF.


Unknown said...

It is also interesting to compare with video of ADF Essentials running on Glassfish server on the same hardware.

Andrej Baranovskij said...

On previous ADF/WLS releases, Glassfish was running faster -


John Sim said...

Are you also connecting to MCS or hosting on JCS?
Just thinking because of the licenses.. Otherwise I'd be using JET :)

Andrej Baranovskij said...

This is local example, not hosting it. Let's wait when JET will be OpenSource, to use it in production systems :)


Unknown said...

Hi Andrejus,
How do you set basic authentication while calling the rest service?
Kindly suggest.


Andrej Baranovskij said...

Good point, I will need to check this.


Unknown said...

Hello Andrejus,

First of all, thank you very much for your contribution. It really helped me to start with my development on JET. Secondly, how can I display a list from the response of a web service like the one you have in this example?

Thanks in adavance!


Andrej Baranovskij said...


Do you want to display a list instead of table? There is list component provided by JET, you can use it.


rjahn said...

If you're still interested in a solution for the basic authentication problem:
(search: Basic authentication)

Use it with care :)

Andrej Baranovskij said...

Thanks, i will take a look - your solution is interesting.


Unknown said...


I am unable to get rest service response from HTTP analyzer when i deploy in Weblogic in JDev 12.2.1, but i am getting data from AppModule(BC) Tester.

I got below error.

Error 401--Unauthorized
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.2 401 Unauthorized
The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.46) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity MAY include relevant diagnostic information. HTTP access authentication is explained in section 11.

Thanks in advance,

Andrej Baranovskij said...

This means username/password is not constructed correctly during REST request.


Kotresh T M said...

Hi Andrejus,

I have created ADF BC rest web service and trying to use same web service in oracle JET application. Both GET and POST working fine from postman rest client. But same when I try to invoke using JET application, I will get below mentioned error
POST 500 (Internal Server Error)

In the ADF BC log, it shows

java.lang.ArrayIndexOutOfBoundsException: 1

Below is the code snippet I am using to invoke rest webservice from jet application,


type: 'POST',
async: false,
crossDomain: true,
headers: {"Accept": "application/json; text/html;"},
data: JSON.stringify(dataObject),
success: function (data, textStatus, jqXHR) {
console.log("Passed in value:"+JSON.stringify(dataObject));

//console.log("Inside Successfunction:"+geturl.getResponseHeader("REQ_RESPONSE"));

error: function (jqXHR, textStatus, errorThrown) {
console.log("Error thrown inside error function:"+errorThrown);
// ("Error : " + textStatus);

my dataobject is as follows

var dataObject = {
"Id": 3,
"Firstname": "kot",
"Lastname": "tm",
"Createdon": "1989-07-20T00:00:00+05:30"

Could you please tell what mistake i am doing. Since it is working fine using postman but in JET application I am seeing the issue

Andrej Baranovskij said...

Try to test using code described in this post: It seems similar, I'm also using POST there.


funcelot said...

@Kotresh T M:

JSON.stringify(dataObject) - there is an extra call of JSON.stringify

Andrej Baranovskij said...

Thanks for follow up.