Errors running builder ‘JavaScript Validator’ on project

I got this annoying exception on every auto build of my Dynamic Web Project.

“Errors occurred during the build.
Errors running builder ‘JavaScript Validator’ on project ‘GenieAlert’.
java.lang.NullPointerException”

I was trying to stop the validation of Javascript in the Eclipse properties with the following options,

Windows -> Preferences -> Validation -> Client-side JavaScript Validator -> Checked Manual & Unchecked Build.

This option didn’t work out, then I realized that it happens only on the Build time. The following option came in handy to do that.

Project -> Properties -> Builders -> Unchecked ‘Javascript Validator’

Sometimes when you try to run the Web projects from eclipse on servers these JavaScript validation stops the deployment of the project on servers stating “JavaScript Validation Exception found”. I hope the above solutions will help in those situations too.

Dynamically adding HTML components using JavaScript

At times there will be requirements to dynamically add a scetion of HTML multiple times in UI. This can be achived by using JavaScript. One of the implementation for such a scenario is addressed in the following example.
Requirement:
In thie example, there was a need to add a row of three Text boxes, select box to be added dynamically to a page on a button click. Validation has to be done to the dynamically added rows.

Design & Usage:

The design of the sample goes like this.

There will be a container to hold the control items, like button to add the component, field to hold the counter. Following the control box an empty container to hold the dynamically added components. Another container just below this, to hold the contents that has to be created dynamically. The contents has to be formulated carefully with the layouts and identifications. To achive the easier identificaiton of the elements inside the components an auto generated ‘ID’ is added to all the elements on the go. To achive this a delimiter is added to all the elements. Here the delimiter used is “ADDIDHERE”. This will be replaced by the counter variable on the go.
Source:
View Sample page.
Download Sample.
Screenshot:

DynaComp

Simple methods to Create, Read and Delete Cookies using JavaScript

Usage:

1. createCookie(name,value,days) – Void function.

name – Name for the cookie to be created
value – Value of the cookie
days(INT – Non Madatory) – Number of days to keep the cookie in browser. If not specified the cookie will expire as soon as soon the browser is closed.

2. readCookie(name) – Returns the value of the cookie.

name – Name given at the time of creation

3. eraseCookie(name) – Void function.

Dependency – createCookie method should be in place.

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0)
return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}