Sharing Xcode 5 projects on SVN with no issues

In order to share Xcode 5 project on SVN, you can do it by doing the following:
1. Choose Xcode -> Preferences.
2. Choose “Accounts” tab.
3. In the “Accounts” tab, click “+” -> “Add Repository”.
4. Enter the SVN Repository information as shown in the screenshot below:
SVN Information Window

P.S. You may face the following error while trying to add SVN repo to Xcode as follows:
xcode cannot verify the identity of the server

In order to resolve this issue, just click "Show Certificate", unfold the disclosure arrow and set the “Trust” option menu to “Always Trust”.

5. After doing these steps, you can choose the local folder ("iOSProjects" for example) in which you want to do svn checkout. You can do this from "Source code" -> "Checkout".

6. Finally, you can create (or place) your Xcode project under your local folder "iOSProjects" to add and commit the project files to SVN.

[jQuery Mobile] Avoiding multiple pageinit executions for separate pages

One of the common problems in jQuery mobile when navigating to a separate page in a separate HTML file is that he “pageinit” event will be triggered each time page is visited. The problem becomes severe when you find that each time you visit the separate page, your “pageinit” event handler is registered +1 more time which makes a great hassle because of the multiple event binding.

Let’s see an example to understand the problem, assume that we have a separate page called “pageA” which includes a JavaScript file that defines “pageinit” event handler as follows:

$(document).on("pageinit", "#pageA", function(e) {
    //Initialization can be done here ...

If you navigate from any page to “pageA”, you will find that in everytime you visit this page, your “pageinit” event handler will be registered and executed, which means that if you visit the page for the second time, you will find “pageinit” event handler executed twice and for the third time, you will find it executed 3 times and so on.

In order to resolve this issue, you will need to un-register the “pageinit” event as follows using $(document).off().

$(document).on("pageinit", "#subscriptionView", function(e) {
    //Initialization can be done here ...
    $(document).off("pageinit", "#subscriptionView");

Doing this workaround makes “pageinit” event handler executing only once each time the page is loaded.

P.S. This behavior does not happen in jQuery mobile when you follow the single HTML file approach which includes all the application pages.

JavaScript Quiz #12

Assume that we have the following short JavaScript code:

    var number = 50;
    var obj = {
        number: 60,
        getNum: function () {
	    var number = 70;
	    return this.number;


Will this code succeed or fail? and if it succeeds, what is the output of the alerts?

Read the complete answer

Container-managed security for Java web applications

Web applications often need to provide security on application access (authentication) and on page access control rules (authorization). It can take a lot of time to implement these requirements from scratch to produce a secure application, but thanks to the Java Servlet specification, such common security requirements can be handled at the container level. This article explains how to apply container-managed security in Apache Tomcat in a Java web application for authentication and authorization:
Read the full article.

TypeError: invalid ‘in’ operand obj

A weird JavaScript error that you may face when using Dojo Ajax for retrieving some JSON data from the server to render on the browser. This error happens because Dojo is unable to process the resulted JSON data which is the case when handleAs attribute is set to “text”.

In order to fix this error, set handleAs attribute to “json” instead of “text” as shown below in the example:

	url: '/SomeServlet',
	handleAs: "json",
	timeout: 3000,
	load: function(data) { /* Success Handling */ },
	error: function(err) { /* Failure Handling */ }

This is my today’s two cent advice.