Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ajax 'Architecture'

 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hopefully directed at the author, but anyone else who has dabbled in Ajax.

I've been having a go at my own Ajax application and paying close attention to the design process at the same time.

In the experience of others, are there best practices in terms of how to define how to delegate application knowledge (eg what does the client 'know', what does the server 'know'), how to define communication, how to prevent the layers blurring into each other?

To extend the question, is there a particular direction you started from and work towards the other side? For example, I mocked a simple client (little or no JS, no server interaction) then I wrote the server. I defined the server interactions in a couple of simple servlets then moved to integrating into the client, but I've been doing the the thin-client thing for too long and I keep making decisions based on that knowledge. My app currently reloads and caches images in JS, I still haven't gotten to the 'Ajax' bit
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started working with Ajax, so here are my few cents.

-I start by building a JS shell that has all the inner workings set.
-Once that works I build the AJAX to get the info to and from the server
-I use DWR for quick setup. So basically JS just calls methods which are mapped to a server's class which returns the data in some structure and changes the state of the page (JS which has already been debugged)
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DWR?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DOM,

Link to DWR: http://getahead.ltd.uk/dwr

Eric
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://getahead.ltd.uk/dwr

Basically a set of tools that let you map JavaScript calls to Java methods.

That way I can tell DWR I have an ClassA with methods doThis and doThat. It should be identified as jsClassA inside my js code. So

<script>

jsClassA.doThis(callback, parameters...);

</script>

Results in ClassA.doThis being called with "parameters..." and the return value being sent to the "callback" function.
 
Christian Gross
Author
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are thinking about writing an Ajax application with some server side part then you should be thinking in SOA terms. Think of your server in terms of exposing services.

Pragmatically I would do the following:

1) Think of your business process.
2) Pick one simple process (eg add invoice)
3) Convert that simple process into a Web Service that is exposed using REST, and the protocol could be either XML, or JSON.
4) Using wget or curl (http command line tool) create a test script to excercise and test your web service.
5) Create an HTML page that includes an XMLHttpRequest and convert the wget or curl script into JavaScript.
6) Write JavaScript to process the data from the XMLHttpRequest.

OK?

Christian
Author: Ajax Patterns and Best Practices
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic