Sunday, January 22, 2017

SQL Bind Variable Support in ADF BC REST

Is not that obvious from Oracle ADF BC REST developer guide how to provide value for bind variable defined directly in the View Object SQL statement. I did research around this and would like to post few hints to make your life easier, if you have same requirement - pass values from REST request to View Object required bind variables. This topic is especially useful, when you want to reuse existing ADF BC implementation for ADF BC REST access.

We are going to use View Object Row Finder. Oracle ADF BC REST developer guide explains how to use Row Finder with View Criteria. In our case we have different situation -  we would like to use Row Finder for required bind variables, referenced directly in SQL statement.

You can't define Row Finder without View Criteria. First trick is to define empty View Criteria, just to be able to define Row Finder - we are not going to use View Criteria functionality, our bind variables are referenced directly in SQL WHERE clause:


Once Row Finder is defined, you are going to see bind variables listed. Keep in mind - this doesn't means bind variables are referenced by Row Finder, they are just listed for possible use. Now main trick - go and define some dummy expression for each bind variable you want to use in REST request (make sure to uncheck - Save expression to groovy file):


This action would generate Groovy expression for each bind variable and list these bind variables under Row Finder. Go to source of View Object to see the structure:


Now remove Groovy expressions assigned to each bind variable - we don't need them, keep only bind variable names assigned to Row Finder:


Visually in the wizard is going to look like there are no changes made - but we keep bind variables under Row Finder tag now:


Bind variables are included directly into SQL statement WHERE clause:


ADF BC REST service is defined in regular way, no special tips here:


This is how REST call looks like: Departments?finder=RESTFilter;depNameVar=IT.locIdVar=1700. We include Row Finder name and two bind variables with values:


In the background we could check ADF BC log, where it prints SQL statement with both bind variables assigned with values:


Download and browse sample application ADFBCRestApp from my GitHub repository - jetcrud.

Wednesday, January 18, 2017

Multi Language Support in Oracle JET

There is great post from Geertjan Wielenga about Translating Oracle JET Applications. If you want to introduce multi language support into JET app - this is great place to start reading from. We are building production Oracle Cloud app with ADF BC REST and JET. This app requires multi language support - English and Lithuanian. I will describe below how we integrated multi language into various areas in the app.

Download or browse through sample application in GitHub repo - JETPlaygroundApp.

In JET we could set default language in index page html root tag. By default it is set to en-US, but it can be set to lt-LT for Lithuanian language or any other language:


Translation texts are located in message bundles. There is one default message bundle for English and translations are located in sub folders. English bundle:


Lithuanian bundle with translations for the same message keys:


Multi language bundle support must be registered in main.js (bundle file name can be anything):


Values for all labels/texts must be defined as observables and initialised from JET translation API by passing message key - this will bring default text:


When language is changed, we need to update observable values and reset language value in HTML tag. I'm changing menu labels as well by re-configuring JET router:


On UI in index.html message key is referenced directly from observable variable:


We can access message key defined in appController from individual JET module UI through $parent. For example, I'm using dueDate message key in incidents module:


Same message key is reused in another module - customers:


This is how language switch looks on UI - language change is available in preferences:


When we switch to Lithuanian language - texts are changed (the ones assigned with translatable messages):


Menu labels are also changes, JET Router is reset:


Labels are change in built-in JET components - such as date. Though is not translated completely for Lithuanian language (Today text remains in English):

Saturday, January 7, 2017

Oracle JET Router API Example

One of the examples of JET Router API usage - sign-in/sign-out implementation. After sign-in we need to change menu structure and allow access to application modules, on sign-out menu structure should be changed again. JET Router API allows to manage application navigation and menu structure from JavaScript. Check complete API methods list here - JSDoc: Class: Router.

Sample application code is available on GitHub - JETPlaygroundApp. This application is generated with JET NavDrawer template and is runnable in NetBeans and from command prompt with Grunt. I was using such Yeoman command to generate it:

yo oraclejet JETPlaygroundApp --template=navdrawer

I have changed index page to stretch to entire width and hamburger button to be always available. This is how sign-in module looks like:


After sign-in, user gets hamburger icon to access menu structure:


Oracle Developer Cloud service UI looks similar, it also gets menu list on the left, user can open it with hamburger icon:


Sign-out is available in the drop-down list:


Router API is used in three places in my sample app:

1. Initial sign-in module setup in appController.js. This is executed when application is initialized. Router is configured here with single module - login. Developer should get root instance, configure it with module list and define array with description how each menu item will look like:


2. On sign-in, when login function is called - we get the same root instance of the router. Configure it with new set of modules, one of them is marked as default, define array with descriptions and reset current navigation. At the end we should sync all changes with Router instance, this is done through sync() method call:


3. On sign-out, when logout functionality is called. We reset router configuration with single login module. Login module is set as default. Here we call Router API method go(). Method doesnt need parameter, it will navigate to default module, if no parameter specified. Depending on URL state, if current module before sign-out is default one, URL will not change - this would require to call sync() method to force sign-in module display. If user is on any other module, not the default one - go() method will navigate to sign-in module automatically:

Friday, January 6, 2017

Oracle ADF - Strategic Oracle Technology

Happy New Year !

There is update for Oracle ADF Statement of Direction dated to November 2016:


You can read full document on Oracle Support site, search for document ID 1985782.1.

To summarise outlined roadmap for Oracle ADF:

1. Oracle continues its commitment to Oracle ADF as a strategic technology

2. Oracle ADF will bring new technologies minimising the negative effect of change (recent examples - ADF BC REST, HTML5 support)

3. In future versions of ADF there will be more focus on JavaScript solutions

4. There are plans for ADF 12.2.1 and beyond

Thursday, December 29, 2016

NetBeans Git Client for JET Versioning and Oracle Developer Cloud Service

I should say I'm happy with how NetBeans Git client works. It offers good performance and resolves conflicts pretty well.

It shows a list of pending changes and also changes colour for changed file name:


Changes can be committed into local repository through informative wizard:


File changes are displayed in very clear way, easy to understand them:


All local changes can be pushed to Oracle Developer Cloud Service Git (or other repository):


Select a branch where to push your work:


Notification about recent update is displayed in Developer Cloud Service console:


We can track changes, do merge requests and merge into trunk in Developer Cloud Service:

Tuesday, December 27, 2016

ADF BC REST 12.2.1.2 Custom Method JDeveloper Workaround

Some of you who would try to implement custom method with ADF BC REST may face JDeveloper 12.2.1.2 wizard issue. JDeveloper 12.2.1.2 wizard is refusing to register ADF BC REST custom method, but it works perfectly on ADF runtime. Seems to be JDeveloper 12.2.1.1 - 12.2.1.2 bug. There is a workaround to modify REST service configuration manually and include custom method binding.

Sample application (available on GitHub - jetcrud). This sample implements custom method in VO implementation class - testCall:


Method is exposed through client interface:


Now if you go to REST service definition and try to enable this method to be included into REST interface - JDeveloper will report error:


Something wrong happens in RSTCustomMethodTab class:


Workaround - add method call into REST service definition manually. I recommend to do it outside of JDeveloper, as it hangs. Change definition in external editor. This is the example for custom method entry:


a

If you take a look into JDeveloper wizard for REST definition, it still shows method unchecked. But you can ignore it:


To execute custom method through REST call, make sure to use POST and specify method name along with parameters in REST request body:


Make sure not to forget to provide action Content-Type:


Check section for more info - 22.13.5 Executing a Custom Action.

Monday, December 26, 2016

ADF REST Framework Version 2 (and later) - 12.2.1.2

While building our new Oracle Cloud application with ADF BC REST and JET, I have discovered not announced feature in ADF BC REST 12.2.1.2. Starting from 12.2.1.2 ADF BC REST offers runtime versions. This is configurable in adf-config.xml file or could be provided through REST request header. ADF 12.2.1.2 supports version 1, 2 and 3. Version 2 offers better query support, while version 3 provides better response for hierarchical data - 16.5.2 What You May Need to Know About Versioning the ADF REST Framework.

You can specify version in adf-config.xml, as per documentation:


Version 2 offers more advanced support for data query. Besides query by example from version 1, we could use advanced query syntax - 22.5.4 Filtering a Resource Collection with a Query Parameter. For example, like operator wasn't supported in version 1:


It is supported in version 2. I could specify version 2 directly in REST request header as in example below:


Download ADF BC REST sample from GitHub repository - jetcrud.