July 28, 2016

Reverse 2048

Reverse 2048  - A new android app from me.

This is a fun, addictive and a puzzle board game. It is a cool variant of traditional 2048 puzzle game.

The challenge is to reach from the #2048 tile to #1 tile. When tile with number 1 is created, the player wins the game.

Click here for more details of the app.


June 28, 2016

How to invoke HTTP methods like PUT,PATCH and DELETE using HttpURLConnection

     I am invoking REST web services using HttpURLConnection. Few of the rest services have operations like PUT, PATCH, and DELETE. While passing these methods in setRequestMethod() of HttpURLConnection object, I am getting the below error in response.

java.net.ProtocolException: Invalid HTTP method: PATCH

     To avoid this error and to let the HttpURLConnection execute these methods, there is a workaround which is to override the http method we are invoking. And the procedure to do it is,
  • Invoke any accepted http method like GET or POST
  • Pass the new method value to the header parameter "X-HTTP-Method-Override" to Override the method 
Below is the example: 
            URL url = new URL(mcsPatchAPIURL);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Accept", "application/json");
            conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
            conn.setRequestProperty("X-HTTP-Method-Override", "PATCH");

To get an idea about these methods:

GET: To get the details of a resource
PUT: To update the existing resource
POST: To create a new resource
PATCH: To update the existing resource partially
DELETE: To delete the existing resource

May 13, 2016

Cordova Plugin is not added to MAF

Issue:
I faced an issue where I could not able to add few cordova plugins to Oracle MAF application. I could able to select the plugin but after selected, it is not added to MAF and not showing any error also.

Solution:
Check the value of the attribute xmlns of the tag plugin in the plugin.xml file under the corddova plugin folder. Generally it is

xmlns="http://cordova.apache.org/ns/plugins/1.0"

Change the value to as below
xmlns="http://apache.org/cordova/ns/plugins/1.0"

Now re-try to add the plugin to MAF.

February 29, 2016

Adding a custom css/skin file to a MAF application

When we want to apply our own css to a Oracle MAF application, we need to configure a custom css file to it. Below is the procedure to know how to add a custom css/skin file to a MAF application.
  • Right click on ApplicationController project -> select CSS File -> enter css file name. Below is the default path of the file to be created. Here my css file name is myskin.css
            /ApplicationController/public_html/resources/css/mycss.css

  • Open maf-config.xml which is under Application Resources and check the skin family and version
         Ex
             <skin-family>mobileAlta</skin-family>
             <skin-version>v1.4</skin-version>

  • open maf-skins.xml which is under the project "ApplicationController" and create an xml entry like below
        <?xml version="1.0" encoding="UTF-8" ?>
         <adfmf-skins xmlns="http://xmlns.oracle.com/adf/mf/skin">
         <skin-addition id="s1">
         <skin-id>mobileAlta-v1.4</skin-id>
         <style-sheet-name>resources/css/myskin.css</style-sheet-name>
         </skin-addition>
         </adfmf-skins>

Where <skin-id> is the combination of skin-family and skin-version of maf-config.xml file seperated by "-" and enter the css file path for <style-sheet-name>.

February 3, 2016

How to integrate or configure InAppBrowser Cordova plugin in Oracle MAF

I have created a video to show how to integrate a Cordova plugin in Oracle MAF to show InAppBrowser in a mobile app. Click here to watch the video. This video also shows the procedure to integrate any other Cordova plugin with the Oracle MAF.

The MAF version 2.1 with JDeveloper 12c is used in this example.



Below are the steps to integrate the InAppbrowser Cordova plugin in Oracle MAF.
  1. Download the inappbrowser cordova plugin from https://cordova.apache.org to your machine
  2. Create a MAF application in JDeveloper
  3. Unzip the downloaded inappborwser plugin in your machine
  4. Copy and paste the plugin folder under the ViewController project folder in the MAF application
  5. Register or Configure the plugin in MAF application's maf-application.xml
  6. White list the domain you want to open in the app browser
  7. Create a java class and write a method to invoke inappbrowser api
  8. Create a button in amx page to bind the method
  9. Select the simulator and run the app
  10. Inappbrowser is ready. On click of the link in the app, a browser will be opened in the app with the given url. You can also choose to display extra buttons and navigation on this browser by changing the parameters passed in the java script api.