Tuesday, September 20, 2016

Slides Available - End-to-End Cloud: Oracle Java Cloud, Oracle Mobile Cloud Service, Oracle MAF, and Oracle JET [CON2388]

I have completed my OOW'16 session [CON2388] today. For those of you who could not attend it, check slides online (I will post sample code later, read more about the session here):


Saturday, September 17, 2016

Dynamic Flying Dashboard UI in ADF 12.2.1.1

I took my old sample application implemented in 2010 - Dynamic Flying Dashboard UI Shell and upgraded it to recent ADF 12.2.1.1. It runs pretty well, without major changes - this proves ADF migration between releases can be smooth (well, not always in practice - but let's be positive).

I have recorded gif to give you an impression how it runs and how UI switch works in ADF UI panel dashboard component:


There are four blocks in the dashboard, user can remove each of the blocks or select predefined group of blocks:


It is possible to maximize selected block to occupy more space:


Some of the blocks can be minimized and only a subset of blocks will be displayed:


Such functionality is implemented with out of the box ADF UI components - af:panelStretchLayout, af:panelSplitter and af:panelDashboard. Depending on selection, block is minimized, displayed or maximized:


Toolbar items (minimize, maximize and restore) are implemented in the separate JSF container and reused in the main page:


Hopefully you will find such use case interesting and will have a chance to apply in the project. Download sample application - ADFIntegrationDashboard_v2.zip.

Thursday, September 8, 2016

Workaround for ADF 12.2.1.1 Match Media Behavior Tag

If you run ADF 12.2.1.1 application with adaptive UI implemented by af:matchMediaBehavior tag (ADF 12.2.1 Responsive UI Improvements), most likely you will face Null Pointer Exception in Match Media Behavior tag class. Apparently af:matchMediaBehavior tag expects default value to be set on UI component. If default value is not set explicitly, it fails to read it and generates exception (this was not the case in ADF 12.2.1).

This example contains three af:matchMediaBehavior tags, properties orientation and styleClass are not set on panel spitter by default:


This leads into Null Pointer exception on runtime:


To fix this, we can set default values for orientation and styleClass explicitly. Propety styleClass can be assigned with empty value, this helps:


UI is loaded this time:


UI is resized on narrow screen - panel splitter orientation is changed:


Download application with workaround for af:matchMediaBehavior - ADFResponsiveUIApp_v2.zip.

Wednesday, September 7, 2016

Speaking on Oracle OOW'16 - MCS, JET, ACS, JCS and MAF

With Oracle Open World'16 around the corner, I have prepared demo use case including Mobile Cloud Service (MCS), JavaScript Extension Toolkit (JET), Application Cloud Service (ACS) and Java Cloud Service (JCS). I will describe what Oracle Cloud offers to implement end-to-end enterprise solution.

This year I will be speaking on two sessions.

- End-to-End Cloud: Oracle Java Cloud, Oracle Mobile Cloud Service, Oracle MAF, and Oracle JET [CON2388]

Monday, Sep 19, 12:30 p.m. - 1:15 p.m. | Moscone West - 2012

I will be co-presenting and talking about Oracle JET Hybrid implementation:

- Building Enterprise-Grade Mobile Apps with Oracle JET and Cordova [CON5731]

Thursday, Sep 22, 12:00 p.m. - 12:45 p.m. | Moscone West - 2016

Demo use case will be based on JET application running on Application Container Cloud and integrated with Mobile Cloud Service (MCS) REST services:


There will be JET Hybrid application listening for MCS notifications:


You will learn how to process notifications:


Display and synch data from MCS in JET Hybrid application:


Functionality to be described during [CON2388] session:

MAF:

- Integration with MCS

JCS:

- ADF BC REST development and deployment
- Security implementation

ACS:

- JET application depoyment process with Node.JS application

JET:

- JET application implementation tips & tricks
- JET oAuth security integration with MCS
- JET and REST calls
- JET and MCS notifications

MCS:

- Custom API implementation tips & tricks
- Security configuration
- MCS DB API
- MCS Notifications API
- MCS Connector API to call ADF BC REST

Tuesday, August 30, 2016

Generic BigDecimal Formatter in ADF 12.2.1.1

I have implemented couple of improvements for BigDecimal formatter based on ADF 12.2.1.1. Originally formatter was implemented and described in this post - Handling Format for BigDecimal Numbers in ADF BC. New improvements: option to support trailing zeros and disabling number rounding.

1. Support for trailing zeros

If you type number 3000.10, BigDecimal type attribute will keep it as 3000.10. But in database it will be saved without trailing zero as 3000.1. This would lead to "Another user has changed the row" issue, as there will be mismatch between value in DB and value in ADF BC.

Try to enter 3000.10:


Save, change any other field and try to save again. You will get error:


Double check in DB, value is saved without trailing zero. Thats the reason for the error, data mismatch:


Solution is to parse entered value into BigDecimal without trailing zeros in generic formatter class:


2. Disabling number rounding

By default when you type 2500.209 (and if only 2 digits after dot are allowed):


This will be rounded to 2500.21:


While rounding can be useful, most of the time it will be confusing. There is a way to disable rounding by removing af:convertNumber tag for UI component. Formatting still will be applied through generic formatter class:


If user enters incorrect number, instead of rounding it - formatting error message will be displayed:


Download sample application - ADFFormattingApp_12211.zip.

Sunday, August 28, 2016

Oracle JET Hybrid Receiving Mobile Cloud Service Notification

Oracle JET Hybrid enabled with Cordova Push plugin can receive notifications sent from Oracle Mobile Cloud Service (MCS). You should read how to setup infrastructure in this article - Your first Push notification based Oracle JET Hybrid application!. I will focus on implementation steps and will provide working sample app for download.

Sample JET hybrid application provides login functionality. During login we register device ID with MCS service, this allows to receive notifications:


After login is completed, default dashboard page is displayed. At this point, application is ready to receive notification (even if application will be closed or mobile device screen is locked):


Notification from MCS can be sent programmatically from API implementation. I will show this in the next posts. For now we can use MCS UI to test if notification is working. Mobile Backend provides functionality to send notifications. I can target notification to specific user:


If mobile device registration was successful during login in JET Hybrid, MCS wil send notification and you should see confirmation message (if there will be error, this means registration from Oracle JET Hybrid was unsuccessful):


In few seconds you should see notification received and displayed in notifications screen:


Select notification and it will navigate directly to the app and pass notification message. This would allow to parse it do certain action in the app, for example refresh data, etc.:


To verify if registration with MCS was done correctly during login, you can check logs in Mobile Backend. There must be REST POST /register call logged, just after GET /login:


It would not work to send notification, if there is no Client defined in MCS Backend. You can read more about it from the article mentioned above. Make sure to specify all keys correctly, pointing to Google Cloud Messaging (if you are targeting for Android):


Let's take a look into implementation on JET Hybrid side. Login success callback invokes method to register device to receive push notifications from MCS:


Make sure Cordova Push plugin is installed into your app, otherwise PushNotification will be undefined. It gets registration ID from Google and makes another call to handshake with MCS:


I'm invoking wrapper method, which in turn have access to MCS SDK module in my JET app:


MCS SDK method registerForNotifications is invoked, where REST POST call is made to register device with MCS and allow to receive notifications:


Download sample application (this contains only JET implementation JS/HTML, you should copy it into root src folder of your JET hybrid app) - jet_mcs_notifications.zip.

Saturday, August 20, 2016

Oracle JET and Mobile Cloud Service Authentication with OAuth

I will describe with practical example, how to authenticate against MCS in Oracle JET using OAuth. This is based on sample app from my previous post - Oracle JET and Application Container Cloud (with MCS Integration) (download sample app from there). It would be useful to read through MCS documentation - Authenticating with OAuth in Individual REST Calls.

Oracle JET sample application provides login form:


If login is successful, REST call is done and MCS returns data:


In order to authenticate using OAuth, we need to use Application Key defined in MCS Mobile Backend:


Go to Mobile Backend settings screen and note down OAuth property values for Client ID and Client Secret. We are going to use these values in JET application, to initialize OAuth authentication:


There is one test user defined in Mobile Backend - redsam. We can use these user to login from JET over OAuth:


MCS offers to download SDK Java Script code, we could use it in JET application, to authenticate against MCS service through OAuth, Basic or Facebook login. Download SDK from getting started page:


I'm using mcs.js from MCS SDK, you could find helper method in this class - it executes REST POST to authenticate through OAuth and gets temporary access token in return. This token can be used for subsequent requests in the same session:


There is one more wrapper JS file - mbe.js. Here you define mobile backend connection keys. Authentication type is specified as oAuth:


Make sure to add mcs.js module into main.js paths:


Key point - mbe.authenticate() method (call it from JET module, make sure to reference mbe module in require block). Provide username/password and callbacks for login success and login failure:


In login success callback, I'm reading temporary token and passing it through header Authorization : Bearer. This token can be used for REST requests to MCS:


UI component is displayed when authentication is successful: