Changing the moveTo attribute in “dojox/mobile/Heading” dynamically

One of the known issues of the Dojo mobile is that when the Dojo mobile heading has a moveTo attribute, the value of the moveTo attribute cannot be changed once the widget is created. This means that the moveTo attribute will cause the back button to be always going to the initial view id that is binded to the attribute.

In order to resolve this issue (to support, for example, dynamic back navigation), you can destroy the widgets inside the and then re-create the widgets again. Let’s see how to do this. The following code snippet shows the mobile heading element in the HTML file:

    <h1 data-dojo-type="dojox/mobile/Heading" data-dojo-attach-point="dynamicHeading">
    <!-- Other elements -->

And in the "onBeforeTransitionIn" of the view, you can call the buildHeadingDynamic("someView") function which destroys the descendants of the heading and then re-create it again with the new moveTo value.

buildHeadingDynamic : function(backView) {
  var dynamicHeading = this.dynamicHeading;

  var heading = new ({label:"Heading", fixed:"top", back:"Back", moveTo:"#" + backView});

Overriding Android back button behavior in Apache Cordova

If you are using Apache Cordova for building a native application on mobiles using HTML, CSS, and JavaScript. You may need to override the default behavior of the back button on the Android mobiles to implement your application specific back button behavior.

In order to do this, you can register an event handler on the "backbutton" event on the document object but before you do this, you need to make sure that the device is ready using the "deviceready" event as follows.

// In the initialization ...
document.addEventListener("deviceready", deviceReadyHandler, false);  

function deviceReadyHandler () {
    document.addEventListener("backbutton", backButtonHandler, false);

function backButtonHandler(e) {
    //Here implement the back button handler

What the JavaScript Unit Testing book covers?

The JavaScript Unit Testing book is a comprehensive practical guide that illustrates in details how to efficiently perform and automate JavaScript testing for web applications using the most popular JavaScript unit testing frameworks.

The book starts by explaining the concept of JavaScript unit testing and by exploring the bits of an interactive Ajax web application. Throughout the book chapters, the JavaScript part of the web application is tested using popular JavaScript unit testing frameworks (Jasmine, YUITest, QUnit, and JsTestDriver). The book illustrates how to generate JavaScript test reports, how to automate running the tests in the build and the continuous integration environments, and how to make all of the mentioned JavaScript unit testing frameworks work together in order to test the web applications in the most efficient way.

After reading this book, you will learn everything you need to know in order to make efficient JavaScript tests for the web applications. You will learn how to generate test and code coverage reports, how to automate running the JavaScript tests, and the bits of the JavaScript testing by following the book practical hands-on detailed examples.

You can order the book from:

Finally, I would like to thank all of the persons that worked with me in order to produce this book (Acquisition Editor, Commissioning Editors, Technical Editors, Copy Editors, Project Coordinator, Proofreaders, Graphics Designers, Production Coordinator) and certainly the technical reviewer of this book Allan Lykke Christensen.

JSF Exception Handling

Everyone who develops Java EE web applications needs to pay attention to exception handling. When a program encounters an error, developers can display friendly messages for end users, which increases their trust in the application. Also, by adding adequate exception handling, you can troubleshoot and debug application defects. Since version 2.0 the JavaServer Faces framework has supported an exception handling mechanism to provide a centralized place for handling exceptions in JSF applications. In this article, I explain how to utilize the JSF exception handling mechanism using a practical example. I published this article in Wazi:

The Easiest way to check empty Objects in JavaScript

It is a very common requirement that is needed by many JavaScript developers to check if an object is empty in JavaScript without having to write more than one line of code. In the old days, you usually had to make the following for … loop in a common function isEmpty in order to check if the object is empty:

function isEmpty(myObject) {
    for(var key in myObject) {
        if (myObject.hasOwnProperty(key)) {
            return false;

    return true;

Thanks to ECMAScript 5, you can now just use the Object.keys() function to check the object keys, so you can check if the myObject (for example) is empty as follows:

Object.keys(myObject).length == 0

I wish that this tip can be useful for you.

How failing Project Managers can cause harm to team members

In this post, I would like to mention a lesson. A lesson that can be useful for both project managers and software developers. Today, I know that a developer in India is died of a stroke because of the stress she has from her Project Manager. After hearing this piece of news, I felt very sad and started thinking about the environment that this pathetic developer was working in. How she was stressed from her project manager to a degree that causes her heart to stop working.

The funny thing that I know is that in the second day, the PM (Project Manager) makes the team members work until midnight and after that he told them “This is enough for today. I do not want to lose another team member”.

Looking at these words, you will find that this is an example of insanity in the software development world where such a failing PM look at team members as machines (NOT humans). He will be sorry if a team member dies before he delivers his/her work. Such PMs want to deliver the project even if all of the team members die in other words the project will be delivered on the dead bodies of the team.

What we can learn from here is, For project managers:
1. You have to plan reasonably. A developer cannot work for 16 hours daily for a month in order to deliver the project in time.
2. You have to understand the limits of the people. I know that your role is to push in order to deliver on time and with-in the budget but in the same time, you have to get the feedbacks from the team members in order to know their states. This will help you in avoiding killing people (indirectly) by PUSHING, PUSHING and PUSHING.

For developers:
1. You have to discuss the plan with the project manager. Do not accept the plan as is unless it is a reasonable plan.
2. You have to push back if you find yourself flooded with the tasks. You have to discuss that all of these tasks are not possible to be done with-in the planned time, in this case, the project manager will have to re-plan in order to avoid the project slippage.

This is all what I have for this real sad story that I really wish it will never happen again in the future of the software development.

Creating DB2 Stored Procedure from the command line

In order to create a DB2 stored procedures from the command line, all what you need to do is:
1. Place "@" at the end of your "CREATE PROCEDURE" script as follows:

CREATE PROCEDURE myScheme.myProcedure
IN someParameter BIGINT
-- Some SQL statements


2. Let’s assume that the script file name which contains the stored procedure sql is "someScript.sql", In order to execute the DB2 stored procedure creation script, run the following command from the command line:

db2 -td@ -svf someScript.sql

After running the command, you should see the success message as follows:

"DB20000I  The SQL command completed successfully.

DB2 Getting the current database server timestamp

Sometimes, you may need to get the current stamp of the database server if you need for example to calculate the difference between the entry creation time and the current time.
In order to get the current database server timestamp in DB2, you can get it by querying the sysdummy1 table in the sysibm schema as follows: