SlideShare a Scribd company logo
Grails and Ajax
Grails & Ajax
1. What isAjax?
2. Grails inbuiltsupport for Ajax
3. Some Cute examples
4. Questions
3
Session Agenda
● The technology was originally developed by Microsoft to power a web-
based version of itsOutlook e-mail software. Microsoft implemented Ajax as
an ActiveX control that could be used by its browser, Internet Explorer, and
be called from JavaScript to perform asynchronous browser requests
● The advantage of the approach isthat the browser doesn’t have to refresh
the entire page to interact with the server
● We have to write browser-specific code to load XMLHttpRequest object
● Grails tags did thisthingautomatically
● Writing Browser Specific JavaScript code can become rather repetitive and
tedious. Fortunately, there are Ajax frameworks that encapsulate much of this
logic, ranging from the simple (such as Prototype) to the comprehensive
(such asDojo)
4
AJAX
The browser calls some JavaScript, which in turn creates the XMLHttpRequest
object that isable to make the remote call. When the remote call has been
made, the XMLHttpRequest object then invokes the callback (in this case the
processRequest function), which in turn displays the alert
Ajax Flow
5
Grails uses prototype library to provide support for ajax
Include this line on the page where you are using ajax
<g:javascript library="prototype"/>
6
Grails Support For Ajax
Some of the basic tags are as follows:
RemoteLink
– <g:remoteLink action="showTime"update="time">
• Show thetime!
</g:remoteLink>
•
<divid="time">
• </div>
– def showTime ={
– render "Thetime is${newDate()}"
– }
– Remote link calls an action at server and updates a div tag on
success/failure
7
<g:formRemote
name="loginForm"
url="[controller:'user',action:'login']"
update="loginBox">
...
</g:formRemote>
<divid="loginBox">
</div>
def loginBox ={
//process formhere
render "Success"
}
Alternatively you can use submitToRemote tag as well
8
Form Remote
<select
onchange="${remoteFunction(action:'bookbyname',update:[success:'great'
, failure:'ohno'], params:''bookName=' +this.value')}">
– <option>first</option>
– <option>second</option>
– </select>
– Creates a remote javascript function that can be assigned to a DOM
event to call the remote method
9
Remote Function
<g:formRemoteaction="login"
before="setDefaultValue(this);"
update="loginBox"
name="loginForm">
...</g:formRemote>
<divid="loginBox"></div>
<script type=”text/javascript”>
function setDefaultValue(x){
//somecode here
}
</script>
def loginBox ={
//process formhere
render "Success"
}
10
Executing Code Before and After a Call
<g:formRemote url="[controller:'user',action:'login']"
onLoading="showProgress();" onComplete="hideProgress();"
update="loginBox" name="loginForm">
...
</g:formRemote>
ListOfevents
onSuccess : Called when the remote call issuccessful
onFailure : Called when the remote call begins to load the response
onLoaded :Called when the remote call has loaded the response
onComplete :Called when the response has been received and any
updates arecompleted
onERROR_CODE : Called for specific error codes such as on404
11
Handling Events
Grails provides an extremely useful tag to help implement the search feature—
the <g:remoteField> tag. As you might guess from the name, <g:remoteField> is
a text field that sends itsvalue to the server whenever it changes..
<divid="searchBox">
Instant Search:<g:remoteField
name="searchBox"
update="musicPanel"
paramName="q"
url="[control er:'store', action:'search']"/>
</div>
12
Ajax-Enabled Form Fields
OnClicking a link you gotta fetch a template to update a div
onclick="fetchTemplate('$createLink(action:'todo',controller:'dashBoard')}',
this.id);"
function fetchTemplate(url, id) {
jQuery.get(url, {ajax: 'true'}, function(todo){
jQuery('#todoTab').html(todo);
});
}
def todo ={
– //do someprocessing
// render atemplate
render (template:'someTemplate')
}
13
Some Cute Codes
Getting a JSONresponse
Ajax–like File Upload . (In-House researchproject)
14
Some Cute Codes
• Given the number of small snippets of code that get rendered, it wil come as
little surprise that badly designed Ajax applications have to deal with a
significantly larger number ofrequests
• The firstthing to remember isthat an Ajax call isa remote network call and
therefore expensive. Ifyou have developed with EJB,you will recall some of
the patterns used to optimizeEJB remote method calls. Things such as the
Data Transfer Object (DTO) are equally applicable in the Ajax world
• Fundamentally, the DTO pattern serves as a mechanism for batching
operations into a single call and passing enough state to the server for
several operations to be executed at once. This pattern can be equally
effective in Ajax, given that it isbetter to do one call that transmits a lot of
information than a dozen small ones
15
A Note on Ajax and Performance
• Caching isprobably the most important technique in Ajax development
and,where possible, should be exploited to optimize communications
with theserver
• Debugging istough (yikes....)
16
A Note on Ajax and Performance
1.www.grails.org
2.DGG
17
References
Contact us
Our Office
Client
Location
Click Here To Know More!
Have more queries on Grails?
Talk to our GRAILS experts
Now!
Talk To Our Experts
Here's how the world's
biggest Grails team is
building enterprise
applications on Grails!
Ad

More Related Content

What's hot (20)

Introduction to HTML, CSS, and JavaScript for Web Development
Introduction to HTML, CSS, and JavaScript for Web DevelopmentIntroduction to HTML, CSS, and JavaScript for Web Development
Introduction to HTML, CSS, and JavaScript for Web Development
Qurinom Solutions
 
Optimizing and Profiling Golang Rest Api
Optimizing and Profiling Golang Rest ApiOptimizing and Profiling Golang Rest Api
Optimizing and Profiling Golang Rest Api
Iman Syahputra Situmorang
 
Upload files with grails
Upload files with grailsUpload files with grails
Upload files with grails
Eric Berry
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and Tuning
Simone Bordet
 
Grails Connecting to MySQL
Grails Connecting to MySQLGrails Connecting to MySQL
Grails Connecting to MySQL
ashishkirpan
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
Shai Yallin
 
Rest assured
Rest assuredRest assured
Rest assured
Yaniv Rodenski
 
Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19
José Paumard
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
Sébastien Saunier
 
Connecting Connect with Spring Boot
Connecting Connect with Spring BootConnecting Connect with Spring Boot
Connecting Connect with Spring Boot
Vincent Kok
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
VMware Tanzu
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Pei-Tang Huang
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
Jeevesh Pandey
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Shiju Varghese
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
José Paumard
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
Json Web Token - JWT
Json Web Token - JWTJson Web Token - JWT
Json Web Token - JWT
Prashant Walke
 
Introduction to HTML, CSS, and JavaScript for Web Development
Introduction to HTML, CSS, and JavaScript for Web DevelopmentIntroduction to HTML, CSS, and JavaScript for Web Development
Introduction to HTML, CSS, and JavaScript for Web Development
Qurinom Solutions
 
Upload files with grails
Upload files with grailsUpload files with grails
Upload files with grails
Eric Berry
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and Tuning
Simone Bordet
 
Grails Connecting to MySQL
Grails Connecting to MySQLGrails Connecting to MySQL
Grails Connecting to MySQL
ashishkirpan
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
Shai Yallin
 
Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19
José Paumard
 
Connecting Connect with Spring Boot
Connecting Connect with Spring BootConnecting Connect with Spring Boot
Connecting Connect with Spring Boot
Vincent Kok
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
VMware Tanzu
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Shiju Varghese
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
José Paumard
 

Viewers also liked (20)

Object Oriented JavaScript - II
Object Oriented JavaScript - IIObject Oriented JavaScript - II
Object Oriented JavaScript - II
TO THE NEW | Technology
 
Lesson10 preterit
Lesson10 preteritLesson10 preterit
Lesson10 preterit
Lauren
 
Annotating images-animation
Annotating images-animationAnnotating images-animation
Annotating images-animation
sathma
 
Het nieuwe werven
Het nieuwe wervenHet nieuwe werven
Het nieuwe werven
Alliander
 
Final presentation
Final presentationFinal presentation
Final presentation
marshall
 
Murphy
MurphyMurphy
Murphy
Rcabellocaja
 
Office 365 voor het onderwijs
Office 365 voor het onderwijsOffice 365 voor het onderwijs
Office 365 voor het onderwijs
IT-Workz
 
Cell block 33 script
Cell block 33 scriptCell block 33 script
Cell block 33 script
sathma
 
The body
The bodyThe body
The body
Lauren
 
Winning and nurturing leads in a web 2.0 environment; ShipServ and why conten...
Winning and nurturing leads in a web 2.0 environment; ShipServ and why conten...Winning and nurturing leads in a web 2.0 environment; ShipServ and why conten...
Winning and nurturing leads in a web 2.0 environment; ShipServ and why conten...
John Watton
 
Presentation of medivel
Presentation of medivelPresentation of medivel
Presentation of medivel
sathma
 
Traditional mural vs non traditional mural
Traditional mural vs non traditional muralTraditional mural vs non traditional mural
Traditional mural vs non traditional mural
sathma
 
FUKUYAMA BASE WORKSHOP Vol18 Theme
FUKUYAMA BASE WORKSHOP Vol18 ThemeFUKUYAMA BASE WORKSHOP Vol18 Theme
FUKUYAMA BASE WORKSHOP Vol18 Theme
noteproject
 
Blogging as part of your content marketing strategy
Blogging as part of your content marketing strategyBlogging as part of your content marketing strategy
Blogging as part of your content marketing strategy
John Watton
 
Design for Motivation - Intrinsic and extrinsic motivation in design
Design for Motivation - Intrinsic and extrinsic motivation in designDesign for Motivation - Intrinsic and extrinsic motivation in design
Design for Motivation - Intrinsic and extrinsic motivation in design
Thijs de Vries
 
gasdj456djkdi3353452
gasdj456djkdi3353452gasdj456djkdi3353452
gasdj456djkdi3353452
cephas3
 
Campaigns are dead - long live content.
Campaigns are dead - long live content.Campaigns are dead - long live content.
Campaigns are dead - long live content.
John Watton
 
Pontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11gPontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11g
Leandro Santos
 
3 different methods to publicise our presentation
3 different methods to publicise our presentation3 different methods to publicise our presentation
3 different methods to publicise our presentation
sathma
 
Lesson8 presentverbs
Lesson8 presentverbsLesson8 presentverbs
Lesson8 presentverbs
Lauren
 
Lesson10 preterit
Lesson10 preteritLesson10 preterit
Lesson10 preterit
Lauren
 
Annotating images-animation
Annotating images-animationAnnotating images-animation
Annotating images-animation
sathma
 
Het nieuwe werven
Het nieuwe wervenHet nieuwe werven
Het nieuwe werven
Alliander
 
Final presentation
Final presentationFinal presentation
Final presentation
marshall
 
Office 365 voor het onderwijs
Office 365 voor het onderwijsOffice 365 voor het onderwijs
Office 365 voor het onderwijs
IT-Workz
 
Cell block 33 script
Cell block 33 scriptCell block 33 script
Cell block 33 script
sathma
 
The body
The bodyThe body
The body
Lauren
 
Winning and nurturing leads in a web 2.0 environment; ShipServ and why conten...
Winning and nurturing leads in a web 2.0 environment; ShipServ and why conten...Winning and nurturing leads in a web 2.0 environment; ShipServ and why conten...
Winning and nurturing leads in a web 2.0 environment; ShipServ and why conten...
John Watton
 
Presentation of medivel
Presentation of medivelPresentation of medivel
Presentation of medivel
sathma
 
Traditional mural vs non traditional mural
Traditional mural vs non traditional muralTraditional mural vs non traditional mural
Traditional mural vs non traditional mural
sathma
 
FUKUYAMA BASE WORKSHOP Vol18 Theme
FUKUYAMA BASE WORKSHOP Vol18 ThemeFUKUYAMA BASE WORKSHOP Vol18 Theme
FUKUYAMA BASE WORKSHOP Vol18 Theme
noteproject
 
Blogging as part of your content marketing strategy
Blogging as part of your content marketing strategyBlogging as part of your content marketing strategy
Blogging as part of your content marketing strategy
John Watton
 
Design for Motivation - Intrinsic and extrinsic motivation in design
Design for Motivation - Intrinsic and extrinsic motivation in designDesign for Motivation - Intrinsic and extrinsic motivation in design
Design for Motivation - Intrinsic and extrinsic motivation in design
Thijs de Vries
 
gasdj456djkdi3353452
gasdj456djkdi3353452gasdj456djkdi3353452
gasdj456djkdi3353452
cephas3
 
Campaigns are dead - long live content.
Campaigns are dead - long live content.Campaigns are dead - long live content.
Campaigns are dead - long live content.
John Watton
 
Pontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11gPontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11g
Leandro Santos
 
3 different methods to publicise our presentation
3 different methods to publicise our presentation3 different methods to publicise our presentation
3 different methods to publicise our presentation
sathma
 
Lesson8 presentverbs
Lesson8 presentverbsLesson8 presentverbs
Lesson8 presentverbs
Lauren
 
Ad

Similar to Grails and Ajax (20)

Node azure
Node azureNode azure
Node azure
Emanuele DelBono
 
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek
PROIDEA
 
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic StackDocker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic Stack
Jakub Hajek
 
Mobile webapplication development
Mobile webapplication developmentMobile webapplication development
Mobile webapplication development
Ganesh Gembali
 
concept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJSconcept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar TechnologiesRob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
george.james
 
Ajax Performance
Ajax PerformanceAjax Performance
Ajax Performance
kaven yan
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
Yoann Gotthilf
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
Asanka Indrajith
 
Dwr
DwrDwr
Dwr
Suhas Kamble
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Chalermpon Areepong
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
Thomas Fuchs
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
dominion
 
ITI006En-AJAX
ITI006En-AJAXITI006En-AJAX
ITI006En-AJAX
Huibert Aalbers
 
Google app-engine-cloudcamplagos2011
Google app-engine-cloudcamplagos2011Google app-engine-cloudcamplagos2011
Google app-engine-cloudcamplagos2011
Opevel
 
Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWR
gouthamrv
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
Knoldus Inc.
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)
Hendrik Ebbers
 
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek
PROIDEA
 
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic StackDocker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic Stack
Jakub Hajek
 
Mobile webapplication development
Mobile webapplication developmentMobile webapplication development
Mobile webapplication development
Ganesh Gembali
 
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar TechnologiesRob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
george.james
 
Ajax Performance
Ajax PerformanceAjax Performance
Ajax Performance
kaven yan
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
Yoann Gotthilf
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Chalermpon Areepong
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
Thomas Fuchs
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
dominion
 
Google app-engine-cloudcamplagos2011
Google app-engine-cloudcamplagos2011Google app-engine-cloudcamplagos2011
Google app-engine-cloudcamplagos2011
Opevel
 
Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWR
gouthamrv
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
Knoldus Inc.
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)
Hendrik Ebbers
 
Ad

More from TO THE NEW | Technology (20)

10 Best Node.js Practices you Need to Know!
10 Best Node.js Practices you Need to Know!10 Best Node.js Practices you Need to Know!
10 Best Node.js Practices you Need to Know!
TO THE NEW | Technology
 
10 Pragmatic UX techniques for building smarter products:
10 Pragmatic UX techniques for building smarter products:10 Pragmatic UX techniques for building smarter products:
10 Pragmatic UX techniques for building smarter products:
TO THE NEW | Technology
 
12 Key points which make Swift more effective than Objective C
12 Key points which make Swift more effective than Objective C12 Key points which make Swift more effective than Objective C
12 Key points which make Swift more effective than Objective C
TO THE NEW | Technology
 
Gulp - The Streaming Build System
Gulp - The Streaming Build SystemGulp - The Streaming Build System
Gulp - The Streaming Build System
TO THE NEW | Technology
 
Grails Spring Boot
Grails Spring BootGrails Spring Boot
Grails Spring Boot
TO THE NEW | Technology
 
AWS Elastic Beanstalk
AWS Elastic BeanstalkAWS Elastic Beanstalk
AWS Elastic Beanstalk
TO THE NEW | Technology
 
Content migration to AEM
Content migration to AEMContent migration to AEM
Content migration to AEM
TO THE NEW | Technology
 
AWS CodeDeploy
AWS CodeDeployAWS CodeDeploy
AWS CodeDeploy
TO THE NEW | Technology
 
Big Data Expertise
Big Data ExpertiseBig Data Expertise
Big Data Expertise
TO THE NEW | Technology
 
An introduction to Object Oriented JavaScript
An introduction to Object Oriented JavaScriptAn introduction to Object Oriented JavaScript
An introduction to Object Oriented JavaScript
TO THE NEW | Technology
 
MongoDb and NoSQL
MongoDb and NoSQLMongoDb and NoSQL
MongoDb and NoSQL
TO THE NEW | Technology
 
(AWS) Auto Scaling : Evening Session by Amazon and IntelliGrape Software
(AWS) Auto Scaling : Evening Session by Amazon and IntelliGrape Software(AWS) Auto Scaling : Evening Session by Amazon and IntelliGrape Software
(AWS) Auto Scaling : Evening Session by Amazon and IntelliGrape Software
TO THE NEW | Technology
 
MongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behlMongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behl
TO THE NEW | Technology
 
Cloud Formation
Cloud FormationCloud Formation
Cloud Formation
TO THE NEW | Technology
 
BigData Search Simplified with ElasticSearch
BigData Search Simplified with ElasticSearchBigData Search Simplified with ElasticSearch
BigData Search Simplified with ElasticSearch
TO THE NEW | Technology
 
JULY IN GRAILS
JULY IN GRAILSJULY IN GRAILS
JULY IN GRAILS
TO THE NEW | Technology
 
Grails Spock Testing
Grails Spock TestingGrails Spock Testing
Grails Spock Testing
TO THE NEW | Technology
 
Getting groovier-with-vertx
Getting groovier-with-vertxGetting groovier-with-vertx
Getting groovier-with-vertx
TO THE NEW | Technology
 
Introduction to Kanban
Introduction to KanbanIntroduction to Kanban
Introduction to Kanban
TO THE NEW | Technology
 
Introduction to Heroku
Introduction to HerokuIntroduction to Heroku
Introduction to Heroku
TO THE NEW | Technology
 
10 Best Node.js Practices you Need to Know!
10 Best Node.js Practices you Need to Know!10 Best Node.js Practices you Need to Know!
10 Best Node.js Practices you Need to Know!
TO THE NEW | Technology
 
10 Pragmatic UX techniques for building smarter products:
10 Pragmatic UX techniques for building smarter products:10 Pragmatic UX techniques for building smarter products:
10 Pragmatic UX techniques for building smarter products:
TO THE NEW | Technology
 
12 Key points which make Swift more effective than Objective C
12 Key points which make Swift more effective than Objective C12 Key points which make Swift more effective than Objective C
12 Key points which make Swift more effective than Objective C
TO THE NEW | Technology
 
An introduction to Object Oriented JavaScript
An introduction to Object Oriented JavaScriptAn introduction to Object Oriented JavaScript
An introduction to Object Oriented JavaScript
TO THE NEW | Technology
 
(AWS) Auto Scaling : Evening Session by Amazon and IntelliGrape Software
(AWS) Auto Scaling : Evening Session by Amazon and IntelliGrape Software(AWS) Auto Scaling : Evening Session by Amazon and IntelliGrape Software
(AWS) Auto Scaling : Evening Session by Amazon and IntelliGrape Software
TO THE NEW | Technology
 
MongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behlMongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behl
TO THE NEW | Technology
 
BigData Search Simplified with ElasticSearch
BigData Search Simplified with ElasticSearchBigData Search Simplified with ElasticSearch
BigData Search Simplified with ElasticSearch
TO THE NEW | Technology
 

Recently uploaded (20)

Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 

Grails and Ajax

  • 3. 1. What isAjax? 2. Grails inbuiltsupport for Ajax 3. Some Cute examples 4. Questions 3 Session Agenda
  • 4. ● The technology was originally developed by Microsoft to power a web- based version of itsOutlook e-mail software. Microsoft implemented Ajax as an ActiveX control that could be used by its browser, Internet Explorer, and be called from JavaScript to perform asynchronous browser requests ● The advantage of the approach isthat the browser doesn’t have to refresh the entire page to interact with the server ● We have to write browser-specific code to load XMLHttpRequest object ● Grails tags did thisthingautomatically ● Writing Browser Specific JavaScript code can become rather repetitive and tedious. Fortunately, there are Ajax frameworks that encapsulate much of this logic, ranging from the simple (such as Prototype) to the comprehensive (such asDojo) 4 AJAX
  • 5. The browser calls some JavaScript, which in turn creates the XMLHttpRequest object that isable to make the remote call. When the remote call has been made, the XMLHttpRequest object then invokes the callback (in this case the processRequest function), which in turn displays the alert Ajax Flow 5
  • 6. Grails uses prototype library to provide support for ajax Include this line on the page where you are using ajax <g:javascript library="prototype"/> 6 Grails Support For Ajax
  • 7. Some of the basic tags are as follows: RemoteLink – <g:remoteLink action="showTime"update="time"> • Show thetime! </g:remoteLink> • <divid="time"> • </div> – def showTime ={ – render "Thetime is${newDate()}" – } – Remote link calls an action at server and updates a div tag on success/failure 7
  • 9. <select onchange="${remoteFunction(action:'bookbyname',update:[success:'great' , failure:'ohno'], params:''bookName=' +this.value')}"> – <option>first</option> – <option>second</option> – </select> – Creates a remote javascript function that can be assigned to a DOM event to call the remote method 9 Remote Function
  • 11. <g:formRemote url="[controller:'user',action:'login']" onLoading="showProgress();" onComplete="hideProgress();" update="loginBox" name="loginForm"> ... </g:formRemote> ListOfevents onSuccess : Called when the remote call issuccessful onFailure : Called when the remote call begins to load the response onLoaded :Called when the remote call has loaded the response onComplete :Called when the response has been received and any updates arecompleted onERROR_CODE : Called for specific error codes such as on404 11 Handling Events
  • 12. Grails provides an extremely useful tag to help implement the search feature— the <g:remoteField> tag. As you might guess from the name, <g:remoteField> is a text field that sends itsvalue to the server whenever it changes.. <divid="searchBox"> Instant Search:<g:remoteField name="searchBox" update="musicPanel" paramName="q" url="[control er:'store', action:'search']"/> </div> 12 Ajax-Enabled Form Fields
  • 13. OnClicking a link you gotta fetch a template to update a div onclick="fetchTemplate('$createLink(action:'todo',controller:'dashBoard')}', this.id);" function fetchTemplate(url, id) { jQuery.get(url, {ajax: 'true'}, function(todo){ jQuery('#todoTab').html(todo); }); } def todo ={ – //do someprocessing // render atemplate render (template:'someTemplate') } 13 Some Cute Codes
  • 14. Getting a JSONresponse Ajax–like File Upload . (In-House researchproject) 14 Some Cute Codes
  • 15. • Given the number of small snippets of code that get rendered, it wil come as little surprise that badly designed Ajax applications have to deal with a significantly larger number ofrequests • The firstthing to remember isthat an Ajax call isa remote network call and therefore expensive. Ifyou have developed with EJB,you will recall some of the patterns used to optimizeEJB remote method calls. Things such as the Data Transfer Object (DTO) are equally applicable in the Ajax world • Fundamentally, the DTO pattern serves as a mechanism for batching operations into a single call and passing enough state to the server for several operations to be executed at once. This pattern can be equally effective in Ajax, given that it isbetter to do one call that transmits a lot of information than a dozen small ones 15 A Note on Ajax and Performance
  • 16. • Caching isprobably the most important technique in Ajax development and,where possible, should be exploited to optimize communications with theserver • Debugging istough (yikes....) 16 A Note on Ajax and Performance
  • 18. Contact us Our Office Client Location Click Here To Know More! Have more queries on Grails? Talk to our GRAILS experts Now! Talk To Our Experts Here's how the world's biggest Grails team is building enterprise applications on Grails!