Showing posts with label dojo. Show all posts
Showing posts with label dojo. Show all posts

Thursday, June 28, 2007

Dojo 0.9 Beta scheduled for today

Love Dojo ? Well you have a reason to jump off the roof (in ur swimming pool of course) and get back to ur work stations to adapt your skills to a very different but lightning fast version of dojo. Yes today is the beta launch day of dojo 0.9 and dojo guys have worked very hard on saving your Kb's and CPU cycles. Well those of you who thought that dojo is hard to learn, will be buying food for ever hungry dojo hackers!! 0.9 book is not finished and is a work in progress but those of you who need a porting guide, can smile a little as porting guide is presentable and if you are a quick learner then sufficient.
So get ready with your local test site !!

Read More...

Monday, June 4, 2007

Google Gears and Dojo Offline

Google launched Google gears which helps a developer to make its web application work offline, Google Gears is a set of API which works in tandem with a Local Server, Database and a Worker Pool to enable a web application to work offline. Dojo launched a simillar kind of toolkit called Dojo Offline about a month ago, Its time to watch out performance of both the developer toolkits, though Google has the Big G factor to it .. I am particularly impressed by dojo toolkit which AJAXify your web app in a click of a thumb and also gives you a very rich web 2.0 UI with really sweet widgets to cutify your website. Dojo Offline has this edge of being open source and hassle free IP issues which makes it a better contender to provide a complete solution to the offline paradigm. Its two of my favorites competing and I am gonna be hurt anyway. If I get time to work on google gears (which I have to manage with my placements coming), I will publish some tutorials and examples on ajaxkarma, so keep looking !!

Read More...

Saturday, May 26, 2007

Dijit Form Widgets Tutorial -- TextBox, CheckBox, Button

Lets quickly see these simple Dijit Form Elements, so that we will have more time to invest on fancier one's.
BOOTSTRAPPING:
BootStrapping is still done with good old dojo.js by sourcing this script file in our environment. It does all the work at the background to give u the dojo object.
<script type="text/javascript" src="www_root/js/dojo/dojo.js"></script>
This you will need in any dojo enabled page and dojo.js contain the most important and frequently functions.
DOJO REQUIRES:
To make dijit work You will need to import corresponding Widget Script File in your environment. To parse the widgets you need a parser JS file which can be obtained by
dojo.require ("dijit.util.parser");
This is needed in almost all markup based widget creation, where you create widgets by calling them in html tags.

GETTING STARTED WITH TEXTBOX, CHECKBOX AND BUTTONS:
To make Textbox, checkbox or Button work you will have to dojo require the appropriate JS file in your environment..

Lets see how to define a TextBox in a input tag ...
<input dojoType="dijit.form.Textbox" type=text name="name">


You can set following properties:

trim : Removes leading and trailing whitespace if true. Default is false.
ProperCase: Converts the first character of each word to uppercase if true.
upperCase : Converts all characters to uppercase if true. Default is false.
lowerCase:
Size: Size of the text Box

Following event handlers work as in normal textbox:

onfocus
onblur
onkeyup

Lets see how to use above info ...

<input dojoType="dijit.form.Textbox" type=text name="name" trim="true" propercase="true">

Similarly the obove eventhandlers can be used to call appropriate functions..

Some Functions of TextBox object are
getTextValue
getValue
setTextValue
setValue

Note: You can acess these functions when you create TextBox programatically

Making a TextBox Programatically :
function create_textbox()
{
var parameters = {
name:"email",
trim:"true",
propercase:"true"
};

var text = new dijit.form.Textbox(parameters,dojo.byId("hello"));
text.setTextValue("Value set by setTextValue");
}

<form >
<button dojoType="dijit.form.Button " onClick="create_textbox"> Textbox Programatically
</button>
</form>
</div>
<div id="hello"></div>

BUTTON:
Button is a very rich widget of dijit in terms of looks, functionality and flexibility, As button is used very often in pages the versatility is very much appreciated by developers.
Types of Button We can create are :
1> Normal Cickable Button
2> Drop Down Button ( Using DropDownButton and Menu Widget)
3>Combo Button (Using ComboButton and Menu Widget)

Normal Cickable Button:
We can create a Paser based mark up button as follow:

We need to dojo require the Button Js file by
dojo.require("dijit.form.Button ");

<button dojoType=" dijit.form.Button" onClick="create_textbox">
Click Me!
</button>


Other Attributes of Button are :
Caption: Set caption on button

Function Available to Override:
setCaption: set the caption on button
buttonClick: internal handling of button click

CallBack Funtion:
onClick: Called When button is Clicked

You can have image on button by using <img> tag before closing the button or input tag.

Creating Normal Clickable Button Programatically:
function create_button()
{
var parameters = {
caption:"I m programatically created. Please Click Me",
onClick:"call"
};

var but = new dijit.form.Button(parameters,dojo.byId("hello"));
}

You can call it as callBack handler on onClick or any other way you choose to.

Drop Down Button:
Drop Down Buttons are rendered with the help of Menu Widget and as the Drop Down Button class is in the same JS file as Button class therefore we dont need explicit dojo.require for it. It will come with dojo.require("dijit.form.Button").

Lets see how to create a Drop Down Button quickly ..

<button dojoType="dijit.form.DropDownButton" menuId='FileMenu'>
File </button>

<div dojoType="dijit.PopupMenu" id="FileMenu" toggle="fade" toggleDuration="500" style="display: none;">
<div dojoType=" dijit.MenuItem" caption="New" accelKey="Ctrl+N" onClick="new" </div>
<div dojoType="dijit.MenuItem" caption="Open" accelKey="Ctrl+o" onClick="loadFile"></div>
<div dojoType="dijit.MenuItem" caption="Save" accelKey="Ctrl+s onClick="send"></div>
</div>

dijit.PopMenu and dijit.MenuItem are sourced into environment by dojo.require("dijit.Menu");

Combo Button:
<button dojoType="dijit.form.ComboButton" menuId='FileMenu' onClick=file>
File </button>

and PopMenu can be defined as above in drop down Menu ..

CHECKBOX:
Checkboxes can be used simillarly, we need dojo.require("dijit.form.Checkbox")
They have the same properties as normal Html Checkboxes like

value
checked

<input dojoType="dijit.form.Checkbox" type="checkbox" name="vote" checked="true" value="on" onClick=alert( this.value)>

Other Callback Handlers are:

onChecked
mouseOver
mouseOut

RadioButtons:

<input dojoType=" dijit.form.RadioButton" type="radio" name="album" checked="true" value="snm" onClick=alert(this.value)>

<input dojoType="dijit.form.RadioButton" type="radio" name="album" value="load" onClick=alert( this.value)>

<input dojoType="dijit.form.RadioButton" type="radio" name="album" value="master of puppets" onClick=alert(this.value)>


Closing:
Whew !! Well I have covered almost all aspects of these widgets in accordance to nightly build of 23 May !! We will next see other form elements which are unique to dojo like InlineEditbox,
dateTextBox, CurrencyTextBox, Autocompleter etc ... Keep Checking this blog !!

Read More...

Friday, May 25, 2007

Dojo 0.9 M2 is out !!

Well Many of You already know that Dojo is on its way of a major release which is gonna affect our knowledge of applying dojo in our solutions. Dojo 0.9 Milestone 2 release is out and can be obtained from here.

Dojo Widget has its own new Name and will be called "Dijit" officially, Dojo core is slimmer and faster as per Alex Russel . I downloaded 24th May's nightly build and started looking in it and ran some tests, which were impressive and convincing for the widgets supported till now by dijit. I will start writing on small How To's here to show the usage of Dijit widget which is easier to understand and less clumsier than the overall bash of dojo 0.4 .

I will first cover form widgets of dijit and ways to use them in your pages and then we can move on to more fancy one like Editor and Tree's or we can mix the order, It all depend on the mood and time constraints.

Read More...