How to change pages in a web application in the age of HTML5

More and more web sites stop to use the old way of request-response page switches, where each page switch refreshes the entire page in the browser. Instead they refresh just the data and the page itself is not reloaded. This way has better for performance and it also makes a much smoother user experience. You can see a great example in github where you click on one of the files. In this post I am going to explain how this is achieved step by step. My Demo Requirements: For some reason, almost all of the examples I saw on the internet about this used jquery in one way or another. This post is NOT using any third-party libraries except for history.js script for browsers which do not support the history.pushState feature. I took this script from github. Step 1 – handle links We want that pressing a link will trigger a JavaScript function. You can do that in many ways. I have done it like this: It will go over all the links in the page and will attach a call to function goto(), but it will do it just for the links which points to inner pages. The goto() Continue reading How to change pages in a web application in the age of HTML5

4 JavaScript trivia questions that may help you understand the language a bit better

The next 4 Javascript questions may seem easy to some of you, but I am sure that more than a few will get confused. I believe that these 4 simple questions will help you understand a key feature of the language. Question: What will happen after executing the next JS code? 1. Nothing 2. alert ‘>undefined’ 3. alert ‘>1’ 4. alert ‘>2’ Answer: Nothing, because outer() returned a function but it wasn’t executed. Question: What will happen after executing the next JS code? 1. Nothing 2. alert ‘>undefined’ 3. alert ‘>1’ 4. alert ‘>2’ Answer: alert ‘>2’, because the x that inner() uses is the same x the outer() uses. Question: What will happen after executing the next JS code? 1. Nothing 2. alert ‘>undefined’ 3. alert ‘>1’ 4. alert ‘>2’ Answer: alert ‘>undefined’. Inner uses a variable x which is different than the outer x. The inner x is never initialized Question: What will happen after executing the next JS code? By now the answer should be obvious: alert ‘>3’ .

Use Clover to generate code coverage reports of your integration/automation tests

Clover is a great tool for generating code coverage reports from your unit tests. It can be executed as a plugin in Eclipse, Maven or Ant. However, not everyone knows that it can also be used to collect coverage data of integration tests. This post explains how to collect coverage data with clover at runtime. This post assumes that you already know what are unit and integration tests. This post assumes that you know what Clover is, and already used it either with Eclipse, Ant or Maven. *Let me assured you that even though the directions bellow seems complicated and clumsy at first, after doing them once or twice it is really easy to repeat them. Motivation The default action of Clover is to gather code coverage information during build time or compile time. Therefore, This information includes just the coverage data created by unit tests. If you are developing web applications, you probably use more technologies to test your applications beside unit tests. These technologies may include HTTPUnit/HTMLUnit or automation technologies (like Selenium). These technologies do not work at build time, they can only work during run time, where a web server is up and running and HTTP calls Continue reading Use Clover to generate code coverage reports of your integration/automation tests