SlideShare uma empresa Scribd logo
1 de 56
Baixar para ler offline
Ajax for ColdFusion
    Developers
INTRO




12/07/2006   Rob Gonda :: www.robgonda.com   2
What is Ajax?




12/07/2006      Rob Gonda :: www.robgonda.com   3
What is Ajax?


       AJAX != DHTML
       AJAX Vs. Ajax


12/07/2006      Rob Gonda :: www.robgonda.com   4
What is AJAX? (tech view)

Asynchronous data retrieval using
XMLHttpRequest (or not)
Data interchange and manipulation using
XML (or not)
Dynamic display and interaction using
Document Object Model - DOM (or not)
JavaScript binding everything together
Flash Remoting for JavaScript? Not really,
but close

 12/07/2006   Rob Gonda :: www.robgonda.com   5
Other remote scripting

Hidden IFrame
<img> src
<script> src hack
CSS href hack
JS to faceless Java applets
JS to faceless Flash
NO CONTENT Response
Cookies

 12/07/2006   Rob Gonda :: www.robgonda.com   6
What does it do for us?

Make server hits without full
request/response cycle
Why?
   Reduce server load
   Dramatic improvement in user experience
   Reduced load on browser/script




 12/07/2006     Rob Gonda :: www.robgonda.com   7
Two Types

Ajax On The Edges
   Ajax Widgets
   Enhance your current site
   Add usability
   Degradable
RIA
   Single-page applications
   Replacement for Desktop Applications

 12/07/2006      Rob Gonda :: www.robgonda.com   8
Classic request flow




12/07/2006   Rob Gonda :: www.robgonda.com   9
Partial UI Updates




12/07/2006   Rob Gonda :: www.robgonda.com   10
Rich / Thin Client




12/07/2006    Rob Gonda :: www.robgonda.com   11
Alternatives

Flash
   Features support for vector and raster graphics, a
   scripting language called ActionScript and
   bidirectional streaming of audio and video
Flex
   Declarative RIA development to build RIA’s using the
   Flash Platform
Laszlo
   Declarative RIA development to build RIA’s using the
   Flash Platform or Ajax/DHTML output


 12/07/2006         Rob Gonda :: www.robgonda.com         12
BASICS




12/07/2006   Rob Gonda :: www.robgonda.com   13
XMLHttpRequest (XHR)

A JavaScript Class that lets you make
asynchronous HTTP requests from
JavaScript
Allows to kick off HTTP requests in the
background
A call back JavaScript function is invoked
at each state of the HTTP request and
response

 12/07/2006    Rob Gonda :: www.robgonda.com   14
XHR Methods




12/07/2006     Rob Gonda :: www.robgonda.com   15
XHR Properties




12/07/2006       Rob Gonda :: www.robgonda.com   16
Xml, wddx, json, soap

XML: Extensible Markup Language
   is heavy
WDDX: Web Distributed Data Exchange
   is structured XML, native for ColdFusion
JSON: JavaScript Object Notation
   lightweight computer data interchange format
SOAP: Service-Oriented architectural
pattern
   successor of XML RPC

 12/07/2006      Rob Gonda :: www.robgonda.com    17
JSON

A Data Interchange Format.
Text-based.
Light-weight.
Easy to parse.
Language Independent.
A Subset of ECMA-262 Third Edition (aka
JavaScript).


 12/07/2006   Rob Gonda :: www.robgonda.com   18
XML Vs. JSON
{"menu": {
  "id": "file",
  "value": "File:",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}

<menu id="file" value="File" >
 <popup>
  <menuitem value="New" onclick="CreateNewDoc()" />
  <menuitem value="Open" onclick="OpenDoc()" />
  <menuitem value="Close" onclick="CloseDoc()" />
 </popup>
</menu>


       12/07/2006                   Rob Gonda :: www.robgonda.com   19
JSON and CF

Cfjson: http://jehiah.com/projects/cfjson/
   UDF
   Serializes and de-serializes objects
   Missing de-serializing a recordset
json-serializer:
http://cfopen.org/projects/json-serializer/
   CFC
   Online serializes.


 12/07/2006       Rob Gonda :: www.robgonda.com   20
Testing JavaScript is Not Easy

Browsers
   Firefox, Mozilla, Internet Explorer, Opera, Safari, etc
   Multiple Versions (Main releases, betas, etc)
   Different Security Settings
   Different Browser Plug-ins
Different Operating Systems and Patches
Different CPUs, RAM, Memory, Multiple
Programs running, Multiple browsers open, etc!



 12/07/2006         Rob Gonda :: www.robgonda.com            21
Debugging

HTTP Traffic Sniffers
 Live HTTP Headers
 FireBug
 Fiddler
 Ethereal
   Service Capture


 12/07/2006    Rob Gonda :: www.robgonda.com   22
More on Debugging

Use the DOM Inspector to observe the current
state of your page
   Use MODI for easier live inspection and DOM
   manipulation
Use the JavaScript console / firebug to check for
errors
Use MochiKit logging and interpreter
Use Venkman or Microsoft Script Debugger to
troubleshoot behaviorial problems


 12/07/2006       Rob Gonda :: www.robgonda.com   23
Libraries




12/07/2006    Rob Gonda :: www.robgonda.com   24
AJAX Libraries
Many people / everyone opt for AJAX libraries.
Provides many advantages
   Development time
   Sync / Async
   Serialization
   Multithread / batches
   Error handling
   Logging
   Security, encryption, obfuscation
Disadvantages : NONE!

 12/07/2006         Rob Gonda :: www.robgonda.com   25
Use a Framework

Browsers are different across key areas:
   Event registration and event handling
   HTTP request object implementation
   Document Object Model (DOM) API.
Multithreading, handle request queue or batch
Serialization
Error handling
Logging
Security, encryption, obfuscation

 12/07/2006        Rob Gonda :: www.robgonda.com   26
JavaScript AJAX Libraries
 Libraries
    Adobe Spry
    Dojo (used by Open Ajax, XAP, Kabuki)
    DWR (integrate with Java Struts and JSF)
    jQuery (light-weight, extensible, community involvement)
    Prototype (the most popular, used by RoR)
    YUI (Yahoo User Interface Library)
 Toolkits
    Microsoft Altas (commercial)
    Open Ajax (IBM, Zimbra, Dojo | open source)
    Open Laszlo (Flash and Ajax)
    Tibco GI
    Backbase


  12/07/2006            Rob Gonda :: www.robgonda.com          27
JavaScript Libraries
Dojo (http://dojotoolkit.org/)
   used by Open Ajax, XAP, Kabuki
   Lack of documentation
DWR (http://getahead.ltd.uk/dwr)
   Commonly used with Java, implements Comet
   (Reverse Ajax)
Prototype (http://prototype.conio.net/)
   Used by RoR, script.aculo.us, Rico, Behaviuor
Spry (http://labs.adobe.com/technologies/spry/)
   Simple, limited, lightweight, targeting designers


 12/07/2006         Rob Gonda :: www.robgonda.com      28
JavaScript Libraries

jQuery (http://jquery.com/)
   light-weight, extensible, community
   involvement
YUI (http://developer.yahoo.com/yui/)
   Yahoo User Interface Library
   Well documented
   Well supported
   (wink wink)


 12/07/2006      Rob Gonda :: www.robgonda.com   29
Dojo Ajax Slide

dojo.io.bind() packs a big punch
   Handles text encodings
   Auto-encodes URL components
   Submits forms
   Sync or async
   Coerces return data
Pluggable back-ends


 12/07/2006       Rob Gonda :: www.robgonda.com   30
Dojo other IO

dojo.require(”dojo.io.ScriptSrcIO”);
   Cross-domain and JSON-P
dojo.require(”dojo.io.IframeIO”)
   Background uploads, plugs right into bind()!
dojo.io.updateNode()
dojo.io.encodeForm()



 12/07/2006      Rob Gonda :: www.robgonda.com    31
Problems




12/07/2006    Rob Gonda :: www.robgonda.com   32
Potential Problems
Breaks back button support
URL's don't change as state changes
SEO / Search Engine Indexing
Cross Browser Issues can be a pain
Cross-domain requests (SOA, WS)
Viewable Source Code
Client side business logic
Server Load if not properly coded
Concurrency


 12/07/2006   Rob Gonda :: www.robgonda.com   33
Security Concerns (I)

JavaScript applications are easily decoded
and reengineered
On-demand (server side) loading will not
help if you load your entire application;
keep business logic on server
Obfuscation makes it more difficult, but
can also generate bugs


 12/07/2006   Rob Gonda :: www.robgonda.com   34
Security Concerns (II)
XMLHttpRequest is nothing more than a normal
form submission
   Authentication elements
   Session cookies
   Blank Referrer by default       You should manually set
   this header in your API
Get / Post Verbs are sent in plain text
   Consider encrypting requests and obfuscating
   responses
Developers forget to send sensitive data over
SSL

 12/07/2006        Rob Gonda :: www.robgonda.com             35
Security Rules

Don't trust user input
Do not trust client side validation
Do not trust server side AJAX validation
   Will improve user experience
   Will not reduce code, only increase it.
   You still need to re-validate in the server side
Do not assume every Ajax request is real
Keep you business logic in the server
No framework is yet encrypting transmitted data

 12/07/2006         Rob Gonda :: www.robgonda.com     36
Do not expose your business logic


Most important aspect for Enterprise
Applications
Ajax uses JavaScript, but it does not have to
reside in the client
Use remote calls only as a transport layer
Transport state and commands, not raw data
MVC
   Model must remain on the sever
   View or presentation layer is managed with DOM
   Controller layer simply requests commands and
   dynamically evaluates them


 12/07/2006       Rob Gonda :: www.robgonda.com     37
Main Architectures




12/07/2006   Rob Gonda :: www.robgonda.com   38
What to transport

Data
   XML
   WDDX
   SOAP
   JSON (JavaScript Object Notation)
   JavaScript Native Objects (one way)
Instructions
   JavaScript instructions to be dynamically
   evaluated using eval()

 12/07/2006      Rob Gonda :: www.robgonda.com   39
The Magic Functions

Traditionally you would use DOM
   Cross browser hell
   createNode is a pain


innerHTML
   For modifying content
eval()
   Dynamic expression evaluation

 12/07/2006     Rob Gonda :: www.robgonda.com   40
The eval() function

Dynamic evaluation
   ONLY in the client
   NEVER in the server
       Evaluation in the server could cause xml or sql
       injection.
Evaluate innerHTML instruction
   i.e. result = “ $(‘div1’).innerHTML = ‘text’ ”;
   eval(result);


 12/07/2006          Rob Gonda :: www.robgonda.com       41
Design Patterns




12/07/2006       Rob Gonda :: www.robgonda.com   42
MVC

Model-view-controller (MVC) is a software
architecture that separates an application's
data model, user interface, and control
logic into three distinct components.
Clear distinction between the presentation
layer and business logic




 12/07/2006    Rob Gonda :: www.robgonda.com   43
MVC Diagram




12/07/2006     Rob Gonda :: www.robgonda.com   44
MVC Data Flow




12/07/2006      Rob Gonda :: www.robgonda.com   45
Architecture Recommendations

 Clearly separate content from code - MVC
 Store data that spans pages or sessions
 on the server
 Consider an AJAX centric controller
 Use Facades to provide generalized
 access to data or services
 Use care with fined grained access to
 model/services


  12/07/2006   Rob Gonda :: www.robgonda.com   46
Browser history

iframe technique
   Firefox
        Frame in html    Changes are stored
        Frame in DOM      Changes are not stored
   IE
        All Changes are stored
   Safari
        No Changes are stored



 12/07/2006          Rob Gonda :: www.robgonda.com   47
The back button

Not needed for Ajax snippets or widgets,
but imperative for Ajax applications
The problem is not new; Flash applications
always faced the same
No history means no bookmarks, no
sharing, no back button
Use frameworks


 12/07/2006       Rob Gonda :: www.robgonda.com   48
Fixing the back button

When a user hits the back button, the
browser typically returns a cached version
of the previous page. If the HTTP
response headers have marked the page
as not cacheable, a new request is made.
In most browsers, if a fragment identifier
exists (#) and the user clicks the back
button, history pulls the previous page
from the browser’s cache.

 12/07/2006   Rob Gonda :: www.robgonda.com   49
Degradable Sites

What if JavaScript is disabled?
Href’s + onClicks
Reuse the same logic, just change the
views.
jQuery Example




 12/07/2006   Rob Gonda :: www.robgonda.com   50
Extending Ajax

Flash plays friendly with Ajax
The Flash Platform does not have the
browser limitations
Dojo uses Flash for persistent storage
Flash 8’s IO classes have been used for
file transfers
Rob uses Flash for XML Sockets
messaging services

 12/07/2006      Rob Gonda :: www.robgonda.com   51
Futures Extensions

Flash
SVG
Canvas
JIT
Off-line




 12/07/2006   Rob Gonda :: www.robgonda.com   52
ColdFusion




12/07/2006     Rob Gonda :: www.robgonda.com   53
ColdFusion AJAX Libraries

AjaxCFC
   OOP, CF extends objects, Design Patterns
   Built-in error handling, security, debugging, logging
   Integrates with Model Glue 1.1 / 2.0, Mach II
CFAjax
   First Ajax CF Library
JSMX
   Client side library only
Simple Remote Scripting (SRS)
   Uses iframes
WddxAjax

 12/07/2006          Rob Gonda :: www.robgonda.com         54
Now Let’s code
Ajaxcfc
   Echo, complexObjects, formValidation1, modelglue,
   machii
dojo.0.4.1
   IO, widgets
Jquery
   Contactmanager, formPost, history, tool tips, rating,
   thickbox
Prototype
Spry
XHR

 12/07/2006         Rob Gonda :: www.robgonda.com          55
Thank You

Questions / Comments?
Blog: http://www.robgonda.com
Corp: http://www.ichameleongroup.com
email: rob@robgonda.com




 12/07/2006    Rob Gonda :: www.robgonda.com   56

Mais conteúdo relacionado

Semelhante a Ajax for-coldfusion-developers

Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat ClientPaul Klipp
 
JBoss Architect Forum London - October 2013 - Platform as a What?
JBoss Architect Forum London - October 2013 - Platform as a What?JBoss Architect Forum London - October 2013 - Platform as a What?
JBoss Architect Forum London - October 2013 - Platform as a What?JBossArchitectForum
 
JavaScript on the server - Node.js
JavaScript on the server - Node.jsJavaScript on the server - Node.js
JavaScript on the server - Node.jsRody Middelkoop
 
Technology Trends
Technology TrendsTechnology Trends
Technology TrendsHenry Jacob
 
Python And The MySQL X DevAPI - PyCaribbean 2019
Python And The MySQL X DevAPI - PyCaribbean 2019Python And The MySQL X DevAPI - PyCaribbean 2019
Python And The MySQL X DevAPI - PyCaribbean 2019Dave Stokes
 
Front-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsFront-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsArtur Cistov
 
HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)Kevin Gill
 
Java script Session No 1
Java script Session No 1Java script Session No 1
Java script Session No 1Saif Ullah Dar
 
Big Data Europe: Simplifying Development and Deployment of Big Data Applications
Big Data Europe: Simplifying Development and Deployment of Big Data ApplicationsBig Data Europe: Simplifying Development and Deployment of Big Data Applications
Big Data Europe: Simplifying Development and Deployment of Big Data ApplicationsBigData_Europe
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022NAVER D2
 
Os Henrikson
Os HenriksonOs Henrikson
Os Henriksonoscon2007
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
 
December 4 SDForum Java Sig Presentation
December 4 SDForum Java Sig PresentationDecember 4 SDForum Java Sig Presentation
December 4 SDForum Java Sig PresentationJonathan Abrams
 
Sofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworksSofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworksAndré Neubauer
 
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJSMeteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJSJulio Antonio Mendonça de Marins
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013Alexandre Morgaut
 

Semelhante a Ajax for-coldfusion-developers (20)

Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
 
JBoss Architect Forum London - October 2013 - Platform as a What?
JBoss Architect Forum London - October 2013 - Platform as a What?JBoss Architect Forum London - October 2013 - Platform as a What?
JBoss Architect Forum London - October 2013 - Platform as a What?
 
JavaScript on the server - Node.js
JavaScript on the server - Node.jsJavaScript on the server - Node.js
JavaScript on the server - Node.js
 
Technology Trends
Technology TrendsTechnology Trends
Technology Trends
 
Python And The MySQL X DevAPI - PyCaribbean 2019
Python And The MySQL X DevAPI - PyCaribbean 2019Python And The MySQL X DevAPI - PyCaribbean 2019
Python And The MySQL X DevAPI - PyCaribbean 2019
 
Front-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsFront-end optimisation & jQuery Internals
Front-end optimisation & jQuery Internals
 
Node.js
Node.jsNode.js
Node.js
 
HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Java script Session No 1
Java script Session No 1Java script Session No 1
Java script Session No 1
 
Big Data Europe: Simplifying Development and Deployment of Big Data Applications
Big Data Europe: Simplifying Development and Deployment of Big Data ApplicationsBig Data Europe: Simplifying Development and Deployment of Big Data Applications
Big Data Europe: Simplifying Development and Deployment of Big Data Applications
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
 
ArangoDB
ArangoDBArangoDB
ArangoDB
 
Os Henrikson
Os HenriksonOs Henrikson
Os Henrikson
 
Gwt Deep Dive
Gwt Deep DiveGwt Deep Dive
Gwt Deep Dive
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_final
 
December 4 SDForum Java Sig Presentation
December 4 SDForum Java Sig PresentationDecember 4 SDForum Java Sig Presentation
December 4 SDForum Java Sig Presentation
 
Sofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworksSofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworks
 
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJSMeteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
 

Último

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Ajax for-coldfusion-developers

  • 1. Ajax for ColdFusion Developers
  • 2. INTRO 12/07/2006 Rob Gonda :: www.robgonda.com 2
  • 3. What is Ajax? 12/07/2006 Rob Gonda :: www.robgonda.com 3
  • 4. What is Ajax? AJAX != DHTML AJAX Vs. Ajax 12/07/2006 Rob Gonda :: www.robgonda.com 4
  • 5. What is AJAX? (tech view) Asynchronous data retrieval using XMLHttpRequest (or not) Data interchange and manipulation using XML (or not) Dynamic display and interaction using Document Object Model - DOM (or not) JavaScript binding everything together Flash Remoting for JavaScript? Not really, but close 12/07/2006 Rob Gonda :: www.robgonda.com 5
  • 6. Other remote scripting Hidden IFrame <img> src <script> src hack CSS href hack JS to faceless Java applets JS to faceless Flash NO CONTENT Response Cookies 12/07/2006 Rob Gonda :: www.robgonda.com 6
  • 7. What does it do for us? Make server hits without full request/response cycle Why? Reduce server load Dramatic improvement in user experience Reduced load on browser/script 12/07/2006 Rob Gonda :: www.robgonda.com 7
  • 8. Two Types Ajax On The Edges Ajax Widgets Enhance your current site Add usability Degradable RIA Single-page applications Replacement for Desktop Applications 12/07/2006 Rob Gonda :: www.robgonda.com 8
  • 9. Classic request flow 12/07/2006 Rob Gonda :: www.robgonda.com 9
  • 10. Partial UI Updates 12/07/2006 Rob Gonda :: www.robgonda.com 10
  • 11. Rich / Thin Client 12/07/2006 Rob Gonda :: www.robgonda.com 11
  • 12. Alternatives Flash Features support for vector and raster graphics, a scripting language called ActionScript and bidirectional streaming of audio and video Flex Declarative RIA development to build RIA’s using the Flash Platform Laszlo Declarative RIA development to build RIA’s using the Flash Platform or Ajax/DHTML output 12/07/2006 Rob Gonda :: www.robgonda.com 12
  • 13. BASICS 12/07/2006 Rob Gonda :: www.robgonda.com 13
  • 14. XMLHttpRequest (XHR) A JavaScript Class that lets you make asynchronous HTTP requests from JavaScript Allows to kick off HTTP requests in the background A call back JavaScript function is invoked at each state of the HTTP request and response 12/07/2006 Rob Gonda :: www.robgonda.com 14
  • 15. XHR Methods 12/07/2006 Rob Gonda :: www.robgonda.com 15
  • 16. XHR Properties 12/07/2006 Rob Gonda :: www.robgonda.com 16
  • 17. Xml, wddx, json, soap XML: Extensible Markup Language is heavy WDDX: Web Distributed Data Exchange is structured XML, native for ColdFusion JSON: JavaScript Object Notation lightweight computer data interchange format SOAP: Service-Oriented architectural pattern successor of XML RPC 12/07/2006 Rob Gonda :: www.robgonda.com 17
  • 18. JSON A Data Interchange Format. Text-based. Light-weight. Easy to parse. Language Independent. A Subset of ECMA-262 Third Edition (aka JavaScript). 12/07/2006 Rob Gonda :: www.robgonda.com 18
  • 19. XML Vs. JSON {"menu": { "id": "file", "value": "File:", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }} <menu id="file" value="File" > <popup> <menuitem value="New" onclick="CreateNewDoc()" /> <menuitem value="Open" onclick="OpenDoc()" /> <menuitem value="Close" onclick="CloseDoc()" /> </popup> </menu> 12/07/2006 Rob Gonda :: www.robgonda.com 19
  • 20. JSON and CF Cfjson: http://jehiah.com/projects/cfjson/ UDF Serializes and de-serializes objects Missing de-serializing a recordset json-serializer: http://cfopen.org/projects/json-serializer/ CFC Online serializes. 12/07/2006 Rob Gonda :: www.robgonda.com 20
  • 21. Testing JavaScript is Not Easy Browsers Firefox, Mozilla, Internet Explorer, Opera, Safari, etc Multiple Versions (Main releases, betas, etc) Different Security Settings Different Browser Plug-ins Different Operating Systems and Patches Different CPUs, RAM, Memory, Multiple Programs running, Multiple browsers open, etc! 12/07/2006 Rob Gonda :: www.robgonda.com 21
  • 22. Debugging HTTP Traffic Sniffers Live HTTP Headers FireBug Fiddler Ethereal Service Capture 12/07/2006 Rob Gonda :: www.robgonda.com 22
  • 23. More on Debugging Use the DOM Inspector to observe the current state of your page Use MODI for easier live inspection and DOM manipulation Use the JavaScript console / firebug to check for errors Use MochiKit logging and interpreter Use Venkman or Microsoft Script Debugger to troubleshoot behaviorial problems 12/07/2006 Rob Gonda :: www.robgonda.com 23
  • 24. Libraries 12/07/2006 Rob Gonda :: www.robgonda.com 24
  • 25. AJAX Libraries Many people / everyone opt for AJAX libraries. Provides many advantages Development time Sync / Async Serialization Multithread / batches Error handling Logging Security, encryption, obfuscation Disadvantages : NONE! 12/07/2006 Rob Gonda :: www.robgonda.com 25
  • 26. Use a Framework Browsers are different across key areas: Event registration and event handling HTTP request object implementation Document Object Model (DOM) API. Multithreading, handle request queue or batch Serialization Error handling Logging Security, encryption, obfuscation 12/07/2006 Rob Gonda :: www.robgonda.com 26
  • 27. JavaScript AJAX Libraries Libraries Adobe Spry Dojo (used by Open Ajax, XAP, Kabuki) DWR (integrate with Java Struts and JSF) jQuery (light-weight, extensible, community involvement) Prototype (the most popular, used by RoR) YUI (Yahoo User Interface Library) Toolkits Microsoft Altas (commercial) Open Ajax (IBM, Zimbra, Dojo | open source) Open Laszlo (Flash and Ajax) Tibco GI Backbase 12/07/2006 Rob Gonda :: www.robgonda.com 27
  • 28. JavaScript Libraries Dojo (http://dojotoolkit.org/) used by Open Ajax, XAP, Kabuki Lack of documentation DWR (http://getahead.ltd.uk/dwr) Commonly used with Java, implements Comet (Reverse Ajax) Prototype (http://prototype.conio.net/) Used by RoR, script.aculo.us, Rico, Behaviuor Spry (http://labs.adobe.com/technologies/spry/) Simple, limited, lightweight, targeting designers 12/07/2006 Rob Gonda :: www.robgonda.com 28
  • 29. JavaScript Libraries jQuery (http://jquery.com/) light-weight, extensible, community involvement YUI (http://developer.yahoo.com/yui/) Yahoo User Interface Library Well documented Well supported (wink wink) 12/07/2006 Rob Gonda :: www.robgonda.com 29
  • 30. Dojo Ajax Slide dojo.io.bind() packs a big punch Handles text encodings Auto-encodes URL components Submits forms Sync or async Coerces return data Pluggable back-ends 12/07/2006 Rob Gonda :: www.robgonda.com 30
  • 31. Dojo other IO dojo.require(”dojo.io.ScriptSrcIO”); Cross-domain and JSON-P dojo.require(”dojo.io.IframeIO”) Background uploads, plugs right into bind()! dojo.io.updateNode() dojo.io.encodeForm() 12/07/2006 Rob Gonda :: www.robgonda.com 31
  • 32. Problems 12/07/2006 Rob Gonda :: www.robgonda.com 32
  • 33. Potential Problems Breaks back button support URL's don't change as state changes SEO / Search Engine Indexing Cross Browser Issues can be a pain Cross-domain requests (SOA, WS) Viewable Source Code Client side business logic Server Load if not properly coded Concurrency 12/07/2006 Rob Gonda :: www.robgonda.com 33
  • 34. Security Concerns (I) JavaScript applications are easily decoded and reengineered On-demand (server side) loading will not help if you load your entire application; keep business logic on server Obfuscation makes it more difficult, but can also generate bugs 12/07/2006 Rob Gonda :: www.robgonda.com 34
  • 35. Security Concerns (II) XMLHttpRequest is nothing more than a normal form submission Authentication elements Session cookies Blank Referrer by default You should manually set this header in your API Get / Post Verbs are sent in plain text Consider encrypting requests and obfuscating responses Developers forget to send sensitive data over SSL 12/07/2006 Rob Gonda :: www.robgonda.com 35
  • 36. Security Rules Don't trust user input Do not trust client side validation Do not trust server side AJAX validation Will improve user experience Will not reduce code, only increase it. You still need to re-validate in the server side Do not assume every Ajax request is real Keep you business logic in the server No framework is yet encrypting transmitted data 12/07/2006 Rob Gonda :: www.robgonda.com 36
  • 37. Do not expose your business logic Most important aspect for Enterprise Applications Ajax uses JavaScript, but it does not have to reside in the client Use remote calls only as a transport layer Transport state and commands, not raw data MVC Model must remain on the sever View or presentation layer is managed with DOM Controller layer simply requests commands and dynamically evaluates them 12/07/2006 Rob Gonda :: www.robgonda.com 37
  • 38. Main Architectures 12/07/2006 Rob Gonda :: www.robgonda.com 38
  • 39. What to transport Data XML WDDX SOAP JSON (JavaScript Object Notation) JavaScript Native Objects (one way) Instructions JavaScript instructions to be dynamically evaluated using eval() 12/07/2006 Rob Gonda :: www.robgonda.com 39
  • 40. The Magic Functions Traditionally you would use DOM Cross browser hell createNode is a pain innerHTML For modifying content eval() Dynamic expression evaluation 12/07/2006 Rob Gonda :: www.robgonda.com 40
  • 41. The eval() function Dynamic evaluation ONLY in the client NEVER in the server Evaluation in the server could cause xml or sql injection. Evaluate innerHTML instruction i.e. result = “ $(‘div1’).innerHTML = ‘text’ ”; eval(result); 12/07/2006 Rob Gonda :: www.robgonda.com 41
  • 42. Design Patterns 12/07/2006 Rob Gonda :: www.robgonda.com 42
  • 43. MVC Model-view-controller (MVC) is a software architecture that separates an application's data model, user interface, and control logic into three distinct components. Clear distinction between the presentation layer and business logic 12/07/2006 Rob Gonda :: www.robgonda.com 43
  • 44. MVC Diagram 12/07/2006 Rob Gonda :: www.robgonda.com 44
  • 45. MVC Data Flow 12/07/2006 Rob Gonda :: www.robgonda.com 45
  • 46. Architecture Recommendations Clearly separate content from code - MVC Store data that spans pages or sessions on the server Consider an AJAX centric controller Use Facades to provide generalized access to data or services Use care with fined grained access to model/services 12/07/2006 Rob Gonda :: www.robgonda.com 46
  • 47. Browser history iframe technique Firefox Frame in html Changes are stored Frame in DOM Changes are not stored IE All Changes are stored Safari No Changes are stored 12/07/2006 Rob Gonda :: www.robgonda.com 47
  • 48. The back button Not needed for Ajax snippets or widgets, but imperative for Ajax applications The problem is not new; Flash applications always faced the same No history means no bookmarks, no sharing, no back button Use frameworks 12/07/2006 Rob Gonda :: www.robgonda.com 48
  • 49. Fixing the back button When a user hits the back button, the browser typically returns a cached version of the previous page. If the HTTP response headers have marked the page as not cacheable, a new request is made. In most browsers, if a fragment identifier exists (#) and the user clicks the back button, history pulls the previous page from the browser’s cache. 12/07/2006 Rob Gonda :: www.robgonda.com 49
  • 50. Degradable Sites What if JavaScript is disabled? Href’s + onClicks Reuse the same logic, just change the views. jQuery Example 12/07/2006 Rob Gonda :: www.robgonda.com 50
  • 51. Extending Ajax Flash plays friendly with Ajax The Flash Platform does not have the browser limitations Dojo uses Flash for persistent storage Flash 8’s IO classes have been used for file transfers Rob uses Flash for XML Sockets messaging services 12/07/2006 Rob Gonda :: www.robgonda.com 51
  • 53. ColdFusion 12/07/2006 Rob Gonda :: www.robgonda.com 53
  • 54. ColdFusion AJAX Libraries AjaxCFC OOP, CF extends objects, Design Patterns Built-in error handling, security, debugging, logging Integrates with Model Glue 1.1 / 2.0, Mach II CFAjax First Ajax CF Library JSMX Client side library only Simple Remote Scripting (SRS) Uses iframes WddxAjax 12/07/2006 Rob Gonda :: www.robgonda.com 54
  • 55. Now Let’s code Ajaxcfc Echo, complexObjects, formValidation1, modelglue, machii dojo.0.4.1 IO, widgets Jquery Contactmanager, formPost, history, tool tips, rating, thickbox Prototype Spry XHR 12/07/2006 Rob Gonda :: www.robgonda.com 55
  • 56. Thank You Questions / Comments? Blog: http://www.robgonda.com Corp: http://www.ichameleongroup.com email: rob@robgonda.com 12/07/2006 Rob Gonda :: www.robgonda.com 56