Author Archives

5 Jun 2013
4

XPages Java Tip: Be careful with static variables in your Classes

I learned a very valuable lesson the other day when I relied on the Java Editor to recommend the setting of certain members in my classes. This is a silly mistake that occurred and only cost me about 1.5 hours of troubleshooting, but hopefully others can learn from this and not make the same mistake.

WHO TO THANK

I need to thank the following 4 individuals for assisting me with this issue:

1. Serdar Başeğmez – (Who pretty much knew what the issue was but I didn’t understand him properly. Sorry man)

2. Solly Bronkhorst - (My senior Domino Developer at Ukuvuma, who is quite new to Java, but managed to point out the issue fairly quickly. That’s mad skills Solly)

3. Thimo Jansen - (For really trying hard to help me out. I really appreciate the effort Thimo)

4. Paul Withers – (For providing me an alternative to the below issue in Java. Thanks man)

5. John Dalsgaard and Nathan T Freeman – (For providing valuable feedback on my Blog Post and helping me correct some of my statements which were quite misleading)

LET ME ADD SOME CONTEXT

In my XPages Applications, my Application Logic is designed around the MVC Architecture. For every Application I usually create a “Global Controller” Java class that initializes certain parts of my application and sets a few members. I access the Global Controller via a managed Bean which I store as a Session Scope Object (Session Scope meaning the Object will remain active for the current Notes Database/Application for the current User only).

Inside this Global Controller, I have a few member properties that get populated on load of the application. (e.g. The current Username, e-mail address, roles, etc). In one of my cases these members needed to be used in my XPages as well as in some of my other Java Classes.

WHAT WAS THE PROBLEM?

While I understood how to get a handle on my Managed Bean via my XPages and Custom Controls, I made an assumption on how to get a handle on it in my other Java Objects. I would import the “Global Controller” into my Java Class and reference its members directly.

Everything worked fine for me when I was testing the application, but the moment there was more than 1 user working in the Application, my Global Controller’s members would be overwritten (i.e the username is not mine, but the 2nd user’s. The same for the roles, e-mail address, etc).

It was as if my Global Controller was being stored as an Application Scope Object and not a Session Scope Object.

WHY DID IT HAPPEN?

When I imported my Global Controller into my other Java Objects and started referencing its member properties, the Java editor started returning errors, telling me that my Global Controller’s members need to be Static. It was here that I allowed the Java Editor to make the necessary changes in my code.

So what does it mean to have a static member? From my understanding, Static members are initialized only once and at the start of the execution. When I launched my XPages Application, my static members would be initialized and would then be stored as values to be used by everyone until they were re-initialized. So if I launched the application first (me as John Jardin), the member properties would be populated with my details, which is correct. If a second user launched the application on her side (Susan Smith), the member properties would be changed and would contain her details. This directly affects me and any user who launched the Application prior to Susan.

RESOLUTION

You cannot import a Java Object into another Java Object and assume to get a handle on it the same way you would in XPages via a Managed Bean. At least this is how I understand it. What you need to do in your Java Object is get a direct handle to your Managed Bean, which contains an Instance of your Global Controller.

Let’s say that your facesconfig.xml has the following code that defines your Managed Bean:

<managed-bean>
    <managed-bean-name>GlobalObject</managed-bean-name>
    <managed-bean-class>com.ukuvuma.designmanager.globals.GlobalObject</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

To use this Managed Bean in your Java Object, you’ll need the following code:

FacesContext context = FacesContext.getCurrentInstance();
GlobalObject globals = (GlobalObject) context.getApplication().getVariableResolver().resolveVariable(context,"GlobalObject");

Here you created a variable called “globals” and connected it to your GlobalObject Managed Bean. Now you can continue working with your Global Object in your Java Class. Simple as that.

Till next time. Cheers
John
27 Apr 2013
6

Appcelerator Mobile Dev – Chapter 2: Understanding the Titanium Framework

Welcome to Chapter 2 of the Appcelerator Mobile Development Series: Season 1. In this post I am going to explain how the Titanium Framework works and help you understand the pros and cons of using it. I’ll also touch on the Pricing model as I currently understand it, keeping in mind it changed recently.

At IBM Connect this year I had a “Birds of a feather” session that I facilitated and it was focused around Appcelerator Titanium as a Mobile Development Framework and how well it integrates with IBM Notes/Domino and XPages. Part of the session was to give an overview of which other Mobile Frameworks are available and what are the different ways one can develop for a mobile application. Today I will explain this in my post and go deeper into what Titanium offers that’s quite unique and powerful.

The different ways one can develop for a mobile application

For me, Mobile Applications come in 3 flavors:

1. Native Mobile Applications - An application developed for a specific mobile operating system that uses the OS’s core native UI Controls and Objects.

2. Mobile Web Applications - A mobile friendly web application developed using HTML5, CSS3 and Responsive Techniques, that’s hosted on a Server and accessed via the mobile device’s Web Browser.

3. Mobile Web Application in a native wrapper - A Mobile Web Application running in a Native Wrapper that gets installed as a mobile app on the Mobile Operating System.

To develop Native Mobile Applications, you can either use the Mobile Operating System’s core programming language and SDK, (Objective-C in XCode for iOS, Java in Android SDK for Android, Java in Blackberry SDK for Blackberry, C# in Windows Phone SDK for Windows Mobile), or you could use a cross platform SDK such as Appcelerator Titanium, LiveCode or Xamarin. The problem with trying to develop for each Mobile OS using its core SDK, is that it’s a massive learning curve. Also, to develop 1 Solution and deploy it to iOS, Android, Blackberry and Windows Mobile, would mean developing a mobile app for each Platform, even though it’s the same app. Imagine maintaining or enhancing this 1 solution. Quite scary don’t you think?

For Mobile Web Applications, you can use the following of the many JavaScript and CSS Frameworks available:

- jQuery Mobile
- Dojo Mobile
- Sencha Touch
- Twitter Bootstrap
 

When it comes to Mobile Web Application development, I personally prefer Twitter Bootstrap as it allows me to create 1 Website that’s responsive based on the device’s Screen Resolution. So with a little bit of effort, your Website can auto adjust itself, show/hide components, etc based on the device that loads it. Twitter Bootstrap is also integrated with jQuery Core, which is always a bonus. A good example of an online website that’s developed using Twitter Bootstrap is Collaboration Today (Did you know: Collaboration Today is developed using XPages and is Open Source).

Pretty much any Mobile Web Development framework can be used in a Native wrapper. Phonegap is a very popular framework and is free to use. Another great solution is IBM Worklight, which to me is Phonegap on steroids, but it’s focus is primarily for Businesses.

Overview Of Titanium Studio

Titanium is a free Application Development Platform built on top of Eclipse. You use Titanium to create cross platform native mobile applications using one programming language……JavaScript. This means no Objective-C, Java or C# skills required.

Currently Titanium allows you to create, run and package native mobile applications for iOS and Android. Blackberry is also an option but currently in Beta. Windows Mobile 8 Beta is on the way and should be released toward the end of 2013.

The Titanium Mobile API gives you access to pretty much all of the Native UI and non visual components that make up a Mobile Application. These components include Windows, Views, labels, buttons, switches, dashboards, navigation, local file storage, network access, etc.

In Titanium Studio, you can write, test and debug your mobile apps using both the Simulator and the actual mobile device.

So will my Mobile App be regarded as native?

The short answer is Yes. Let me explain.

When you create and build a mobile app with Titanium, the following happens:

1. Titanium precompiles your JavaScript code to minify it.
2. Titanium then builds a dependency hierarchy of all the Titanium API’s used by your application.
3. The front-end compiler creates native stub files, which include platform-specific native code, a native project file (only when necessary) and code to compile Titanium for a given platform compiler.
4. Titanium then calls the platform-specific compiler tool (e.g. xcodebuild) to compile the native application.

On iOS, your JavaScript is Base64 encoded. On Android, your JavaScript is precompiled to byte code. Your JavaScript code is never converted to Objective-C or Java. This is what differentiates a Titanium Mobile App from a Native Mobile App developed in XCode or Android SDK. This means your mobile app uses a JavaScript interpreter for your application logic. To summarize, there is an extra layer of processing in an Appcelerator mobile native app vs a standard native mobile app.

With all that being said though, everything that’s written to the screen is native. Windows, Scroll Views, sections, dashboards, buttons, switches, sliders, labels, pickers, tab groups, menu bars, animation transitions, popups, activity indicators and much much more.

You have near full access to all the device’s apis including camera, video, audio, sounds, recorder, contacts, accelerometer, geolocation, maps, sqlite storage, file system, calendar, facebook, yahoo, network and yes, much much more.

This means, that with an unnoticeable performance knock because you use JavaScript for your application logic and it has to be interpreted, everything else is native.

Can I use Titanium as a native wrapper for mobile web apps?

The answer is again Yes. Keep in mind that Titanium focuses only on iOS and Android, with Blackberry, Tizen and Windows Mobile 8 on the way.

Titanium has what is called a “WebView”. This contains your html code that references JavaScript and CSS files stored locally in your app. The great news is you can have a combination of native controls and html running in the same application. The even better news is they integrate and communicate with each other.

If you needed to create an app that runs on multiple platforms over and above iOS and Android, then PhoneGap might be the solution to go with, or IBM Worklight for businesses.

What else is worth mentioning about Titanium

Well, they are aggressive when it comes to updates, enhancements and new features. Version 3.1.0 of the Titanium SDK has just being released. With it, comes a 20% performance boost for apps developed for iOS and up to 36% for Android.

From version 3, you can make use of the Alloy MVC Framework. This means more structure in your application, better performance, cleaner code and less development time.

I’ll also note that when iOS 6 was released, 2 weeks later Titanium released their updated SDK to support it. That’s an incredible response time in my book.

There’s much one can still mention for this section, but I’ll leave some for the next chapters.

So what are the downsides of using Appcelerator Titanium?

For starters, you can only build for iOS and Android. I know that Blackberry is in a Beta phase, but Beta versions scare me at the best of times. Appcelerator could easily decide to stop supporting a certain api or funtion that was available in the Beta version. So as far as i’m concerned, I can use Titanium to develop for iOS and Android only.

I’m sure many will agree with me on this one. Their pricing model is terribly confusing. I’ve heard stories of developers using the free version and then being forced to pay a percentage or worse. The good news though is that Appcelerator have simplified their packages and i’ll explain them shortly.

Another downside is their sales team take forever to respond or in some cases don’t respond at all. I understand their Support team are only available mainly for the Paid subscriptions, but I can’t say I’m impressed their sales team not responding to potential sales leads or pricing queries that I submit.

How does the Pricing work?

Appcelerator offers the following 3 packages:

- Titanium Community Edition (Free)
- Appcelerator Platform (Public Cloud Enterprise Edition) = $999 / Month / Named User
- Appcelerator Platform (Virtual Private Cloud Enterprise Edition) = $2 667 / Month / Named User
 

Some quick notes about the Pricing Plans:

1. Everything mentioned in the previous sections are available in the Free version of Titanium.
2. A Named user is a Platform User with an Appcelerator User Account. This is not an end user of the mobile application.
3. All 3 packages offer Cloud Services like Push Notifications, API Calls, Cloud Storage, etc, but the Paid versions offer way more than the free version.
4. The Enterprise version of Titanium has more tools and plugins compared to the Free Version. This includes Code Analyzer, Live View, Profiler, etc.
 

Demos and Examples of Appcelerator Titanium Mobile Applications

There are many Mobile Apps that you can download from Online Stores that were developed using Appcelerator Titanium. Below are a few of them:

1. Firstly, here’s Appcelerator’s App Showcase Pinterest Board, just for reference and screen shots.

2. Then, you’ve got Mobile Apps developed by Elguji.com. These apps are available for download from the iStore and I highly recommend giving them a try.

3. Next is Domino To Go. YouAtNotes created an extension for Titanium to allow Appcelerator developers to connect to IBM Domino environments and take Domino data offline. More of a plugin than an application, but still awesome. They have 2 apps you can download from the iStore to try out.

4. There’s also OpenRest, which is a Mobile Application developed using Titanium and is used to create Food Ordering Portals.

Where can I find more resources on Appcelerator Titanium?

- Appcelerator Video Channel

- Appcelerator Online Documentation

- Follow Appcelerator on Twitter

- Follow #Appcelerator Hash Tag on Twitter

- Titanium Mobile Development Essential Training Course on Lynda.com

- Appcelerator Training Resources

- Book – Appcelerator Titanium: Patterns and Best Practices

- Book – Appcelerator Titanium: Up and Running

What’s next?

This concludes my introduction Posts to Appcelerator Titanium. Hopefully by now you have a good understanding of the Product and you have Titanium installed and the Basic Tab Template running on your iOS and Android Simulator.

In the upcoming posts we are going to be diving into Appcelerator Development. Most of these will be video tutorials and there will be many of them.

I’d love your feedback on this and my other posts. Feel free to argue cases or query something you don’t understand.

Thanks and good luck on your Mobile venture.

Regards
John
23 Apr 2013
4

TIP: What to try if IBM Notes 9 keeps crashing on Apple OSX

Here’s a quick tip for those who experience continuous crashing of IBM Notes 9 on OSX Mountain Lion.

Before installing IBM Notes 9 Beta on my MacBook Pro, I had Lotus Notes 8.5.3 running. I ran the IBM Notes 9 Beta install without uninstalling Notes 8.5.3. Every time I opened IBM Notes for the first time since starting my machine, it would crash and return an error report. Notes would only successfully open after 2-3 attempts. This happened both with the Beta as well as the official release of Notes 9.

What i decided to try next is completely uninstall Notes before installing a fresh copy. This was very tricky because Notes leaves files in multiple places after an uninstall. The below link will assist you with a complete uninstall.

Click here to see the article: “Uninstalling Notes from a Mac OS X client”

Even after uninstalling and re-installing a fresh copy, the same problem occurred. I checked with the online community and they weren’t getting the same problem. Thankfully, my final attempt worked:

SOLUTION

- I uninstalled IBM Notes 9 completely referencing the above link.
- During the new install of IBM Notes 9, I deselected all add-ons except for Social Edition. (I think the IBM Connections add-on was causing the issue)

That’s it. I don’t want to blame IBM Connections for crashing my app, but once removing it, everything worked 100%. It might be that I had IBM Connections installed, but not configured. Who knows.

I hope this helps.

Cheers for now
John

12 Apr 2013
0

Appcelerator Mobile Development – Chapter 1: Installing Titanium

Hi everyone. Welcome to Chapter 1 of my Appcelerator Mobile Development Series. This is my second Blog Post for this series, my first post being the Prologue.

The one thing about Appcelerator that impressed me is how easy it is to get Titanium Studio installed and up and running. There are many tutorials on how to do this. Instead of me re-writing what’s already been written many times, I’ll just be referencing the Documentation I found most helpful and providing my own quick how-to.

The following link will explain the entire process for installing and setting up Titanium Studio. For this post, i’ll be dividing the process into a few simple steps:

Appcelerator Quick Start Guide

Step 1 – Register on Appcelerator’s Site

In order to use Titanium Studio, you will need to register with Appcelerator. This is not only necessary to download Titanium Studio, but you will also be required to log in with your account Username and Password when opening Titanium Studio.

Click here to Register with Appcelerator.

Step 2 – Download Titanium Studio

Titanium Studio is available for Mac (including Mountain Lion), Windows, Linux 32 Bit and Linux 64 Bit. Once you’ve registered on Appcelerator’s site you can click here to download the Studio.

Step 3 – Installing Titanium Studio

For Mac and Windows, installing the Studio is very simple. I’ll be honest and say that I haven’t installed the Studio on Linux, but it seems to be as easy as unpacking the Zip File.

There’s a second phase to installing Titanium Studio. Once you’ve installed it and logged into the Studio, you’ll need to download the latest updates and plugins. You can achieve this by click on the “Help” Menu item on top, followed by clicking on “Check for Titanium Updates“. After all Titanium Updates have been downloaded and installed (Restart of Titanium Studio might be required), repeat the process by clicking on “Help\Check for Updates“. This second option is for the plugins and are compulsory if you want make use of the Alloy Framework, etc.

NOTE: For Windows, you need to be running IE9 or above, else you’ll receive a stupid error after logging into Titanium Studio. It seems that the Appcelerator Dashboard that gets loaded by default doesn’t support IE8 or below.

Step 4: Configuring the SDKs

This Series focuses only on iOS and Android development. Most likely toward the end of this year I’ll publish a series on Windows Mobile and Blackberry Development, depending on when Appcelerator releases the official versions. (Blackberry last I checked is still in Beta).

If you’re running on Mac, you’ll be able to run the iOS and Android SDK. For Windows, you’ll only be able to run the Android SDK. The reason for this is because to develop for iOS you need XCode which only ships with Mac OS. I know some of you are thinking that at least you can run the iOS Simulator, but this is not the case. Titanium Studio does not have its own built in Simulators, but instead uses the Simulators that ship with the relevant SDKs. This is bad news for those who want to test on iPhone on a Windows environment, but if you look on the bright side….if a new version of the iOS or Android SDK gets released, you’ll immediately benefit by testing on that new SDK’s simulator.

Now, before people decide that they will rather pass on Titanium Studio because they only wanted to develop for iOS, there is a silver lining. The way Titanium works, and I’ll explain this in my next chapter, you develop for Android and iOS at the same time. As I said i’ll leave this for the next chapter and will explain it in more detail, but bottom line is: While you’re coding for Android, you’re actually coding for iOS as well, with a few small exceptions.

Coming back to the SDKs….to configure the iOS SDK, make sure you have the latest release of XCode installed on your Mac. This is a huge, but free download from the App Store. You’ll also need Java’s JRE Installed, but Mac is awesome enough to prompt you when relevant to install the JRE and it’ll do everything for you.

To configure the Android SDK is even easier. In Titanium Studio, open up the Dashboard if it’s not already open. (In the Top Toolbar, look for the red triangular Icon with an “a” inside it)

Once the Dashboard is open, click on the Tab “Get Started“, then on the green Android Icon, then finally on the “Update Android SDK“.

Here is where you can select which Android SDKs you want to download and use for testing and Deployment.

Once the above-mentioned is complete, then you’re good to go. You might require some restarts to Titanium Studio and your Operating System.

There is an easy way to quickly test an App on iOS and on Android. Click here to view a quick tutorial on creating and running your first basic app on iOS and Android. Titanium Studio comes with a few basic Templates when creating a New Project. I recommend using the “Tabbed Application” Template when creating a new Titanium Classic Project. Once you’ve provided some basic info and the project is created, you can immediately build the Project to run on iPhone, iPad or Android without adding a single line of code. This will be enough to confirm that everything is working.

 

In my next Post, I’ll discuss Appcelerator and Titanium in a bit more detail, and why I chose to invest time learning and understanding this Framework.

Till next time, enjoy :)
John
11 Apr 2013
5

Appcelerator Mobile Development – Season 1: Prologue

Hi everyone. I’m very excited about my next Blogging Project. Over the past year I’ve had some very decent exposure to Mobile Development, whether Phonegap, jQuery Mobile, Dojo Mobile, XPages Mobile Controls, Appcelerator Titanium, etc.

This is a Prologue to some upcoming Video Tutorials that I am grouping together as “Appcelerator Mobile DevelopmentSeason 1“, where I will be showing everyone how to get started with Appcelerator Titanium Development to build native iOS and Android Mobile Applications.

Season 1 will focus on some basic methods of getting up and running with Native Mobile Development. Our focus will be to create a Mobile Application that runs on iOS and Android which allows the capturing of data, some reports and a couple of other nifty features like SplitWindows for iPads, Pull to Refresh Actions for Views, etc.

We will also be integrating this Mobile App with a Basic Domino XPages Application. I’ll show you how to authenticate with Domino, make use of XAgents and REST Services to push and pull information to an from Domino, as well as triggering your business logic on the Domino side for your Workflow Processes.

Finally, I will be showing you what, at the moment, seem to be best practices for developing mobile Apps using frameworks like commonJS, underscore.js, etc. This will allow us to avoid memory leaks and poor performance by making use of a very basic form of MVC Architecture within our Mobile Application.

My next Blog Post will focus on getting you up and running with Appcelerator Titanium and installing the SDKs for iOS and Android.

I would love your comments, feedback and suggestions regarding this venture. Feel free to post comments against this Blog Post or catch me on Twitter.

Cheers for now
John.