My blog report for 2013

WordPress has created a nice summary of statistics of my blog for the year 2013. The report is available at http://jetpack.me/annual-report/33403624/2013/

Here are some of the highlights –

  • I wrote 15 blog posts in 2013, taking the total posts to 47. So I wrote a lot less posts in 2013 compared to 2012, the year I started this blog.
  • There were 83000 views of the blog in 2013
  • Many of the posts viewed this year were actually written last year. The most popular post was  Passing data between pages in JQuery Mobile followed by  Calling Objective-C code from JavaScript in iOS applications
  • Other than search engines, top two referring sites were stackoverflow.com and jquerymobile.com
  • Visitors came from 168 countries. Most from USA, followed by India and Germany

-Ram Kulkarni

Framework for interacting with embedded WebView in iOS application

Last year around the same time I had written a post about Calling Objective-C code from JavaScript in iOS applications . I created a simple framework for it and described how to use it in that post.

Recently I was working on an application that required WebView to be embedded in the same View Controller along with other native iOS controls. I decided to use the above framework, but knew that  my ViewController class will have to extend WebViewController class of the framework. Though I could have done that, I thought separating the functionality of UIWebViewDelegate from the WebViewController would be a better design. So I replaced WebViewController with WebViewDelegate which implements UIWebViewDelegate protocol. I also removed getInitialPageName method from WebViewInterface.h . So here are the files in the new framework – Continue reading “Framework for interacting with embedded WebView in iOS application”

PhoneGap 3 – My initial experience

PhoneGap 3.0 was released this year in July, but I hadn’t given it a try till a few days back.     I had to start a new PhoneGap project using the latest version (PhoneGap 3.3).
There have been significant changes in the way PhoneGap is installed and project created since PhoneGap 3.0. These changes have been very well documented in the official PhoneGap documentation and various blogs. So installing and PhoneGap 3.3 and creating the first project was a smooth experience.

The problem for me started after the bare minimum project was created. One of the important changes in PhoneGap 3.0 is that every device feature API is a plugin (e.g. contacts, camera etc.) and none of the device APIs are automatically included when you create a project using CLI. You have to add then after you created the project. I was aware of this change and added plugins that I needed using CLI. I then expected to have these APIs available in the application (I created iOS and Android Apps). But they were not. Continue reading “PhoneGap 3 – My initial experience”

Using iOS Native Views in PhoneGap Projects

I am working on an iOS application where I want to use PhoneGap as well as a native iOS View. I want iOS view to be the first page from which user can navigate to a view created by PhoneGap. I have developed iOS applications either completely using PhoneGap or native APIs, but never tried to use both in the same application. So figuring out how to do that took some time and I thought I would share that here.

By the way, if you want to embed PhoneGap WebView into existing iOS project then follow instructions at Embedding WebViews. In this post I am going to explain how to embed native iOS view into a PhoneGap project and set it as the initial page.

First you create a PhoneGap project. I created the project using Command Line Interface of PhoneGap 3.1. Go to the folder where you want to create the project and run following command (I am assuming project name to be iOSPhoneGapProject here)

$ phonegap create iOSPhoneGapProject ram.kulkarni.iOSPhoneGapProject iOSPhoneGapApp

Continue reading “Using iOS Native Views in PhoneGap Projects”

CFSummit2013 – Day1 and cfclient

The day 1 of CFSummit2013 was great. It started with Ben Forta’s keynote. It was, as expected, excellent. He talked about the history of CF, how it’s goal is still the same (productivity) and which features have worked really well and which ones did not work. It was followed by Rakshith’s demos of some of the new features in the next release of ColdFusion (code named Splendor). He touched upon language enhancements, improvements in PDF generation and Mobile features. My demos of mobile features followed Rakshith’s demos. Unfortunately by the time I walked up to the stage to present demos, we had almost ran out of time. So I had to rush through my demos. I had planned to show a demo of debugging mobile application running on a device using ColdFusion Builder, but could not do so. I was told that there were a few issues with audio and display screen during the keynote.

Adobe had set up a table where CF developers could meet and talk to CF team members. Many attendees came there and showed interest in the mobile work flow that we had presented. I also attended Simon Free’s session on Mobile development features in Splendor. He did an excellent job of explaining what cfclient is and some of its features. In the limited time that we had in keynote, we probably could not explain what cfclient was, but I think after Simon’s session people got pretty good idea of what it is. I am looking forward to the second part of Simon’s talk today.

There were many tweets yesterday about cfclient and how it is trying to replace JavaScript. I want to make it clear that it is not true. I can understand that some of the confusion could be because there is no build of Splendor publicly available to try out these features and you will have to base your opinions on what you see in the conference and what other people are taking about it. Having worked closely on mobile features, both on the server and CF Builder, I will try to address some of the concerns about mobile features in Splendor. Continue reading “CFSummit2013 – Day1 and cfclient”

My Experience of building UI of CFSummit2013 mobile app

I am back to writing blog after a gap of nearly two months. Past few weeks had been very busy working on new features of ColdFusion and creating a mobile app for CFSummit2013 . I along with my colleagues Asha and Rakshith had been working on this app for nearly a month, though not necessarily full time. There were two main reasons for building the app 1. to use mobile features of next ColdFusion releases to provide feedback and catch bugs 2. to create a useful app for the attendees of CFSummit.

I don’t know if attendees would find the app useful (I certainly hope so), but we were able to provide a lot of valuable feedback on ColdFusion mobile features and catch many bugs. The application took more time than it should have, because the mobile features of ColdFusion were still under developement. We would hit a bug and would have to wait (if it was a blocking issue) till it got fixed. In many case we did try to work around issues. But the whole process took a lot more time.

But this post is not about mobile features of ColdFusion and how they were used in the CFSummit app. I am going to talk about my experience in creating HTML5 UI for this app, the issues we faced and lessons learnt. Some of the UI issues are still unresolved.

Along with new mobile features of ColdFusion, this app is developed using JQuery, Bootstrap3, PathJS, JQuery Raty, Cordova (PhoneGap) and PhoneGap Build.

Continue reading “My Experience of building UI of CFSummit2013 mobile app”

Code Samples for my book for Eclipse 4.3 (Kepler)

Eclipse 4.3 (Kepler) was released in June this year. There have been some changes to plugin dependencies in E4 RCP applications from version 4.2 to 4.3. I had created sample projects for my book using Eclipse 4.2. If you import those projects in Kepler, then applications would not work.

I have recreated sample projects for Kepler and have submitted them to PACKT. Hopefully they should be available for download soon.

However if you follow through code examples in the book by creating your own E4 RCP projects in Keper, then things should work fine. Eclipse RCP APIs haven’t changed, as far as code samples in the book are concerned. However some of the links mentioned in the book are different for Kepler. They are  –

Application project wizard for E4 has changed a bit in Kepler. Now you have an option to create sample content (menus and views) in the wizard. Earlier you did not have this option and the wizard used to created sample content. This option is turned off by default. If you do not select this, then no menu options would be created. In which case skeleton sample application would look different from what is explained in the book.
If you select the above option, then along with menus and toolbar button, a view is also created.

To try out examples in the book, I would recommend that you select the option to create sample content and then delete the ‘Sample Part’ from Application.e4xmi (it is in Application->Windows->Trimmed Window->Controls->Perspective Stack->Perspective->Controls->PartSashContainer->Part Stack). You can also delete Java source file for this part (SamplePart.java in codesnippetapp.parts package). This will make the skeleton project same as explained in the book.

-Ram Kulkarni

Pre-packaging database with HTML5 Mobile Application

I was discussing with a couple of colleagues of mine yesterday about a HTML5 mobile application that we are developing, and one of the requirements was to pre-package database with the application. A few months back I had created an application that did just that. I thought the solution might be of interest to some of the readers of this blog.

Mobile (or for that matter non-mobile) browsers can create databases for your HTML5 applications. HTML5 provides APIs to create and access the database. But how do you pre-package the database?

The solution is  not really to pre-package the database, but package data that you want a database to initialize with. I don’t think you can really package a SQLite database and ask browser to use it for your HTML5 application. You need to create database and tables when the application is run the first time and then load data packaged with the application. Let’s say we want to create a table called ‘person’ and want to populate this table when the application is run the first time. Continue reading “Pre-packaging database with HTML5 Mobile Application”

Capturing absolute offsets for JavaCC/JJTree tokens

I use JavaCC for generating parsers in Java. And use JJTree to create AST after parsing. JJTree creates nodes of the AST and you can configure JavaCC options to capture tokens in the node – i.e. if you want each node to contain start and end tokens. The default code generated by JavaCC creates Token class with offsets that are relative to the starting offset of the line. It has fields like beginLine, beginColumn, endLine and endColumn. Here the line numbers are absolute line numbers (starting from 1) and column fields contain offsets (again starting from 1) within the corresponding lines.
However many times you want to capture absolute offsets of tokens in the input stream, and not just relative offset in the line. I wish there was a JavaCC option to enable this. But it is not too complex if you want to do it yourself.

To explain how to do this, I will take a grammer file that is generated by the JavaCC wizard of JavaCC Eclipse plugin. This is the default grammer file it generates – Continue reading “Capturing absolute offsets for JavaCC/JJTree tokens”

De/Serializing Recordings in Recordable HTML5 Canvas


Last year I blogged about creating a recordable HTML5 Canvas. I explained how to record strokes/drawings created on a HTML5 Canvas and play them back. There are a couple of comments on that post asking me to explain how to save recordings and load them back. Serialization and deserialization of recordings was on my to-do list for a long time and finally this week I got around to implement it. There are different ways to serialize and deserialize recordings, and I have implemented a simple method – using JSON. The serialized data is a bit verbose because of descriptive variable names I have used, but you can change that easily.

RecordableDrawing (in this script file) function remains unchanged. I have added a new file drawingSerializer.js . Two important functions in this file are serializeDrawing and deserializeDrawing.
serializeDrawing takes a RecordableDrawing object as argument and returns JSON string containing array of recordings.
deserializeDrawing takes a String (serialized data) as argument and returns array of Recording objects.

To see how serialization and deserialization works, follow these steps – Continue reading “De/Serializing Recordings in Recordable HTML5 Canvas”

Social