Professional Documents
Culture Documents
Andrew Ferrier - 2011-03-23-WUG-Building Dojo Web Applications
Andrew Ferrier - 2011-03-23-WUG-Building Dojo Web Applications
Agenda
What is Dojo! Wh- is IBM interested and how does it fit in to WebSphere! A flavor of Dojo ow do we design applications for Dojo! So.e Dojo Best /ractices
/age per state /erhaps with a s.all a.ount of &avaScript for effects or for. validation *raditionall- written with a variet- of technologies 3 Servlets1 &S/s1 etc#
Interaction is aw2ward Slow response ti.e 3 ever- action re7uires a entire page refresh
W89 states that " second is highest acceptable response ti.e for interactive action
Browser using A&A' to co..unicate with server 0ightweight R)S*ful Service 9alls Service :atewa- or other technolog- to pro;- all service invocations
4"5 6ser actions trigger &avaScript call to Aja; engine 4%5 Aja; engine Invo2es as-nch re7uest 485 Server does processing and returns 'M0 to the Aja; engine 4<5 Aja; engine Displa-s the 'M0 in the browser
What is A&A'!
6ses 'M0 **/Re7uest feature of browser to .a2e an **/ invocation without refreshing page
6sed to retrieve data >$? of the ti.e this is for.atted in &S+, 4&avaScript +bject ,otation5
&S+,
@
Acusto.er,a.eBC AAndrew FerrierB Acusto.er eightIn9.BC "$$ Acusto.erAddressesBC D
@ Aaddress*-peBC Aho.eB1 Aaddress0ine"BC A"%8 An-townB1 Aaddress/ostcodeBC AAB"% 89DB E
What is R)S*!
e#g# (rest(custo.er("%8<
0everages
:)*1 /6*1 /+S*1 D)0)*) %$$1 <$"1 <$81 etc# &S+,1 plain te;t
0everages
*hic2-ish client &avaScript code runs in browser )vents on page are used to drive code 4on0oad1 on9lic21 etc###5 );tra data and code are re7uested fro. server using ' Rs1 with as-nc callbac2s in code
Static
0ittle to no &avaScript
8 pri.ar- co.ponentsC
*ree-li2e structure of *M0 tags *hese da-s we use HdivI a lot1 we avoid =st-led= tags li2e HbI#
Decoupling of st-ling and la-out 49SS5 fro. content 4 *M05 Decoupling of code 4&avaScript5 fro. page .odel 4D+M5 )vent-driven progra..ing .odel
Separation of St-ling
Facades R)S*ful services to 6I1 pri.aril- to resolve cross-do.ain securit- restrictions 9an be i.ple.ented in a variet- of technologiesC
&A'-RS Servlets WebSphere )SB and /rocess Server J virtuall- an-thing else that can host **/
Structured code 3 no classes1 .odules 9ross-browser support 3 inco.patibilities1 especiall- with the dreaded I)K 4httpC((www#ieKcountdown#co.(5 ,o support for co.ple; or rich for. controls ard to handle &avaScript conte;t and other aw2wardnesses
So what is Dojo!
Dojo is a set of co..on &avaScript libraries used for creating Aja; and D *M0 web applications httpC((dojotool2it#org
+pen Source 0arge widget collection 4AdijitsB5 /owerful I(+ 4' R5 Data abstraction la-er )vent .anage.ent 0ogging and debugging );tensible .odular architecture Declarative and progra..atic
Rich1 powerful user e;perience1 bridging interactivit- gap 0ow barrier to entr- in .an- environ.ents
With so.e 2ind of service gatewa- technolog-1 can connect to .ost t-pes of bac2end
/art of an overall business solution IBM does .ore than .iddleware Web 2.0 Feature Pack for WAS contains Dojo Building Modern Rich Applications
A Flavor of Dojo
Dojo Base
Dojo ABaseB libraries are Dojo functions that are alwa-s available inside the base dojo#js bootstrap
T)vents 4si.ple connect5 T9olor functions TBrowser detection T6R0 functions TDoc 0oad(6nload oo2s TAni.ation U )ffects
T T T T T T T T
Module 0oader 0ang 6tils U Arra- );tras 9oo2ie functions Puer-1 ,ode U St-le 6tils I(+ 4Aja;5 &S+, serialiRation Fast 9SS St-le .anipulation Deferreds
Dojo 9o.ponents
T Base );tre.el-
co..on functions that are alwa-s available no .atter what else is included /rovided within the dojo#js 4H60kb1 H24kb Ripped5
T 9ore 9o..on functions 0oaded e;ternall );tended ani.ation effects Date parsers Additional I+ above xhr and .ore
+ther Functions
T Dijit InternationaliRed1 accessible for.1 la-out and specialiRed widgets built upon a powerful set of widget functions T Dojo; )ver-thing not -et included in dojo ( dijit Pualit- varies widel Read author notesV T 6tils *ools to create custo. builds );tensions Reduce load ti.e and siRe
Widgets 9ore dSjS
0oading Dojo
I.port an- st-lesheets and the.es -ou wish to use in -our application 0in2 to core dojo.js
9reditsC );cerpt fro. Dojo Funda.entals Aja; );perience presentation b- Ale; Russell
6sing Dijits
Declarative
/rogra..atic
So.e Dijits
6nifor. Input visuals on all browsers dojo#for.#For. provides eas- access to all for. values as a single &S+, object
TDate*e;tBo;
Text In uts
Se!ectors
"thers
#uttons
T Button T DropdownButton T 9o.boButton
T*i.e*e;tBo;
Writing Dijits
*e.plate *M0 4use dojoAttach/oints5 &avaScript with certain call-in functions1 such as constructor()1 buildRendering()1 postCreate()1 etc# 9SS File
So how do we design!
Wirefra.ing to .oc2 up 6I Brea2 6I into Bijits1 specif- each Service 9atalog for :atewa+ther definitions for bac2end services
Wirefra.e page
Designing pages
Brea2 page into re-usable bijits )ach is effectivel- a dijit with a business function
,othing special about bijits 3 -ou don=t need e;plicit support *ie then together using a page controller 4e#g# page controller concept fro. IBM=s Ouba5
Bijits
Service 9atalog
Find a wa- to describe &S+,-based services Decouples i.ple.entation of 6I fro. services Allows i.ple.entation b- separate tea.s ,o for.al te.plates or definitions ,o widel--accepted &S+, sche.a description
If -ou .ust do coarse-grained1 alwa-s describe &S+, envelope in detail Services should alwa-s be short-running
Best /ractices
Develop in 9hro.e or Firefo; with Firebug Don=t Forget Internet );plorer 4esp# I)K5# *o debugC
T T T T
B- Doug 9roc2ford www#jslint#co. &avascript developer=s AhonestB friend );a.ine the entire outputV
3 Do all those globals loo2 right!
T /la- with options T Wor2s with *M0 and &S+, data too T Install &S0int )clipse plugin fro. Roc2 Star Apps
Best /ractices
,eed 9SS e;perience on project 3 an often over-loo2ed s2ill 0earn how to use caching **/ headers to leverage
Best /ractices
Do 0ogging
dojo.provide(my.mod.Foo); dojo.provide(my.mod.Foo); dojo.declare(my.mod.Foo, null, { dojo.declare(my.mod.Foo, null, { constructor: function my_mod_Foo_constructor(args) { constructor: function my_mod_Foo_constructor(args) { !o any initiali"ation #ere !o any initiali"ation #ere var F $ t#is.declared%lass & contructor(): ; var F $ t#is.declared%lass & contructor(): ; console.log(F,'tarting: , args); console.log(F,'tarting: , args); ( ( (); ();
Ma2e sure developers understand &avaScript 4conte;t and as-nc behavior in particular5 :enerate =production= code using an auto.ated buildC httpC((www#ib.#co.(developerwor2s(web(librar(wa-aj-custo.(inde;#ht.l
Further 0earning
Su..ar
Modern1 interactive1 Web %#$ applications are the future Dojo helps -ou build these 7uic2l-1 efficient1 and to a high 7ualit*o designC
andrew#ferrierXu2#ib.#co.