Passing Functions to setTimeout in a for Loop

If you pass an anonymous function as the first argument to setTimeout, and the anonymous function makes use of the for loop’s index, each invocation of the callback uses the same value of the index and you may have undesired behavior To avoid this problem, you need to ensure that each callback gets its ownContinue reading “Passing Functions to setTimeout in a for Loop”

Value of ‘this’

Value of ‘this’ ‘this’ can get quite tricky, especially in event callbacks and setTimeout() or setInterval() handlers. For instance, if you extract a method from an object Also, when code is executed later through setTimeout() , ‘this’ refers to the global ‘window’ object. In both these cases, if you want ‘this’ to refer to theContinue reading “Value of ‘this’”

Heroku supports deploying Java web applications via cmd line

You can upload a WAR file to Heroku and have your web. application up and running on your custom domain. Read this! Its super easy – https://devcenter.heroku.com/articles/war-deployment Essentially, you do the following (these are my internal notes ) 1. Run Maven with package goal to generate a war 3. Login to heroku login 4. GoContinue reading “Heroku supports deploying Java web applications via cmd line”

SEAM and SelectOneMenu example

In JSF, tag is used to render a dropdown box – HTML select element with “size=1” attribute. The following example will show how to select a City from list of Cities and save the Postal Code for a given user using SEAM . In the above code “userForm.postalCode” refers to model “UserForm” with property postalCode,Continue reading “SEAM and SelectOneMenu example”

10 Steps to configure a CRUD Web application using Spring,Hibernate, and JSP

Here are the basic steps (broad overview)  to create a CRUD (Create,Read,Update,Delete) Web application using Spring, Hibernate and a DB Provider such as MySql.  I’ll make another future post to outline the details.   1. Using Eclipse  (Juno is the latest as of this post), setup a Dynamic Web Project and convert it to mavenContinue reading “10 Steps to configure a CRUD Web application using Spring,Hibernate, and JSP”

How To Setup Ruby on Rails with Postgres

Introduction Postgres (or PostgreSQL) is an open source database. Ruby on Rails is an open source web framework written in Ruby. Rails is database agnostic, meaning it can be used with a variety of different databases. By default it assumes that MySQL is being used, but it’s quite easy to use with Postgres instead. ThisContinue reading “How To Setup Ruby on Rails with Postgres”

jQuery.hide( ) issue.

I have discovered a small issue in the jQuery hide() and show() methods, doing a $j(#ID_ELEM).hide() will append a  <span style > attribute causing possibly layout changes on the element you are trying to transform.  This is because the jQuery hide() and show() methods “animate the width, height, and opacity of the matched elements simultaneously” so as the height andContinue reading “jQuery.hide( ) issue.”

Hibernate Saving Collections (using @ElementCollection)

In this example you will learn how to deal with persisting entities that have members that are collections like lists, and maps. We will use the @ElementCollection annotation. to define the collection of Embeddable objects. As a disclaimer, this is not a typical usage of Embeddable objects as the objects are not embedded in theContinue reading “Hibernate Saving Collections (using @ElementCollection)”