Wednesday, October 28, 2009

Dojo 1.3.0 combobox autocomplete with dynamic population of data from database

In Dojo 1.3.0 to refesh an ItemFileReadStore attached to a combobox, we need to
  • set attributes urlPreventCache="true" clearOnClose="true" for the ItemFileReadStore
  • call the close() and fetch() methods of ItemFileReadStore

The below snippets of code have been tested in IE 6 and Firefox 3.5.3

Somefile.jsp


<html>
...
<head>
<script type="text/javascript">
function setComboValue(evt)
{
var comboId = dijit.byId('comboId');
if (comboId && comboId.item)
{
comboId.attr('abbreviation', comboId.item.abbreviation);
}

}
function searchForValue(evt)
{
if (evt.keyCode == 38 || evt.keyCode == 40 || evt.keyCode == 13) {
//do nothing if up arrow, down arrow or enter keys are pressed
}
else
{
var comboId = dijit.byId('comboId');
comboId.store.url = "<%=request.getContextPath()%>/searchChar.htm?myParam=" + evt.target.value;
comboId.store._jsonFileUrl = "<%=request.getContextPath()%>/searchChar.htm?myParam=" + evt.target.value;
stateStore.close();
stateStore.fetch();
}
}

var requestContents = {
override: dijit.byId("comboId").attr('abbreviation')
};

dojo.xhrPost({
url: "/someUrlTOPost.htm",
content: requestContents,
handleAs: "json",
load: function(response, args){
if(response.errors != null) {
console.log("error returned..." + response)

}
else {

console.log("add successful...");
console.log(response);
//do something useful
}
},
error: function(response, args){


}
});
</scrip>
</head>
...
<div dojoType="dojo.data.ItemFileReadStore" jsId="stateStore"
urlPreventCache="true" clearOnClose="true" id="stateStore"
url="<%=request.getContextPath()%>/searchChar.htm?myParam="></div>

<input id="comboId" dojoType="dijit.form.ComboBox"
store="stateStore" autocomplete="false" hasDownArrow="false"
searchAttr="name" onkeyup="searchForValue" searchDelay="500"
onblur="setComboValue" name="abbreviation" />
....
</html>



Json Array for data store ItemFileReadStore

{
identifier:"id",
label: "name",
items: [
{name:"Alabama", label:"Alabama",id:"0"},
{name:"Alaska", label:"Alaska",id:"1"},
{name:"American Samoa", label:"American Samoa",id:"2"},
{name:"Arizona", label:"Arizona",id:"3"},
{name:"Arkansas", label:"Arkansas",id:"4"}
]
}


Refeshing an ItemFileReadStore
by Gary Acord

This is a pretty common need with a pretty simple solution. How do you clear out the existing Data in a store, and populate it with new Data in Dojo 1.2?

The solution is pretty easy. Let’s assume you have an ItemFileReadStore (this works with ItemFileWriteStore as well) named myStore.

This creates an ItemFileRead store and assigns it to the global variable myStore.

Then you can force it to reload as such:

myStore.close();
myStore.fetch();

If you need to change the url of the store (as of Dojo 1.2.3) you can do it like this:

myStore.close();
myStore._jsonFileUrl = newurl;
myStore.fetch();

… and if you have a grid bound to the store, force it to reload

myStore.close();
myStore.fetch();
myGrid._refresh();

Tuesday, October 6, 2009

SKINDRED touring India in Oct 2009

Welsh ragga-metallers SKINDRED have announced their first-ever tour of India. The band will spend the last week of October playing four shows in the country. The details are as follows:

Oct. 25 - The Great India October Festival - Bangalore
Oct. 27 - Hard Rock Café - Mumbai
Oct. 29 - Hard Rock Café - Delhi
Oct. 30 - Hard Rock Café - Bangalore

(source:blabbermouth.net)

Wednesday, September 30, 2009

MR. BIG Japan Tour 2009 Set List

at Kousei Nenkin Hall, Sapporo, Japan
  • Daddy, Brother, Lover, Little Boy
  • Take Cover
  • Green-Tinted Sixties Mind
  • Alive And Kickin’
  • Next Time Around
  • Hold Your Head Up
  • Just Take My Heart
  • Temperamental
  • Classical cover of Holst by Billy, Paul, Pat
  • Pat Torpey Solo incl. The Long And Winding Road, Beatles cover
  • Price You Gotta Pay
  • Stay Together
  • Wild World (Acoustic)
  • Goin’ Where The Wind Blows (Acoustic)
  • Take A Walk (Acoustic – Electric)
  • Paul Gilbert Solo on the Doubleneck
  • Instrumental guitar/bass battle on the Doublenecks (Paul + Billy)
  • The Whole World’s Gonna Know
  • Promise Her The Moon
  • Rock & Roll Over
  • Billy Sheehan Solo
  • Addicted To That Rush

Encore
  • To Be With You
  • Colorado Bulldog
  • I Love You Japan
  • Baba O’ Riley

Tuesday, September 29, 2009

Mr.BIG to tour india in October 2009

Mr.Big - The sensational Rock Super Group of the 90’s as part of their reunion tour will be touring India in october 2009. The band comprises of legendary bassist Billy Sheehan, soulful Eric Martin on vocals, versatile Pat Torpey on drums and guitar virtuoso Paul Gilbert.

Venues:
10th Oct 2009 Bangalore, India Palace Ground (Freeway 19)
12th Oct 2009 Shillong, India Polo Ground
14th Oct 2009 Dimapur, India DDSC Stadium


Javascript - defining and using custom events

This site has a good article that explains the creation and firing of custom javascript events without the use of 3rd party libraries.

Class
var CustomEvent = function() {
 //name of the event
 this.eventName = arguments[0];
 var mEventName = this.eventName;

 //function to call on event fire
 var eventAction = null;

 //subscribe a function to the event
 this.subscribe = function(fn) {
  eventAction = fn;
 };

 //fire the event
 this.fire = function(sender, eventArgs) {
  this.eventName = eventName2;
  if(eventAction != null) {
   eventAction(sender, eventArgs);
  }
  else {
   alert('There was no function subscribed to the ' + mEventName + ' event!');
  }
 };

Register event handlervar myEvent = new CustomEvent("my event");
myEvent.subscribe(function(sender, eventArgs) {
 alert(eventArgs.message);
});

Fire custom event
myEvent.fire(null, {
 message: 'you just witnessed the firing of a custom event called ' + this.eventName + '!'
});

Monday, September 28, 2009

"LOST ANGELS" to perform in India in 2009

LOST ANGELS, featuring singer John Corabi , guitarist Eric Dover, bassist Muddy Stardust and drummer Troy Patrick Farrell , has scheduled the following dates in India:

Sep. 29 - DSSC Stadium - Dimapur, India
Oct. 03 - JN Stadium - Shillong, India

More details to follow.

Tuesday, September 8, 2009

Porcupine Tree gig in Mumbai on 21st Dec 2009

As per their website, 'Porcupine Tree' will be performing in Mumbai, India on 21st December 2009 at the Mood Indigo festival, IIT Bombay.

Check for updates at http://www.moodi.org/ or http://www.porcupinetree.com/