This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Ajax 'Architecture' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax Watch "Ajax New topic

Ajax 'Architecture'

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Feb 08, 2005
Posts: 362
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

Joined: Mar 06, 2001
Posts: 13459

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385

Link to DWR:

Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362

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


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


Results in ClassA.doThis being called with "parameters..." and the return value being sent to the "callback" function.
Christian Gross
Ranch Hand

Joined: Feb 20, 2006
Posts: 85
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.


Author: Ajax Patterns and Best Practices

Author of Ajax Patterns and Best Practices
I agree. Here's the link:
subject: Ajax 'Architecture'
It's not a secret anymore!