• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why do I need AJAX?

 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have heard a lot about ASYNCHRONOUS JAVA SCRIPT AND XML....
also that Google is completely based on AJAX.

But what things can i do using AJAX.
I mean can this book help in exploring ALL the aspects of AJAX and JSF..

I would really love to know how it would extend my power in developing Internet Components
[ April 04, 2006: Message edited by: Ilja Preuss ]
 
Linda Walters
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AJAX is one technique that helps us to create a desktop-like User Experience on the web browser. One of the main things it lets us do is add or change the things that the users sees on the screen without resending and repainting the entire screen. One good example, taken from real life, is an application that has two frames, one above the other, on the browser. The top frame contains a table that is a record list of records in a database. There are up and down arrow so the user can "next" and "prev" through the records as well as double click to select one. The bottom frame contains a rather complex form that displays the full data (sometimes extensive data) for the selected record.

In a classic web app, such as this application is now, each time the user selects a new record from the top frame, the bottom frame is resent in its entirty to the browser. This is not only annoying to the user, it is a huge waste of bandwidth, as the HTML tags that comprise the layout of the form are huge compared to the data that goes into the form's widgets.

AJAX can solve this by sending the form only once when the application is first launched and then on subsequent record selections from the top frame, only the requested data is sent back to the browser. The AJAX JavaScript code then parses out the XML and then the JavaScript changes the data in the form by modifying the DOM.

This is only one example of thousands that could be proposed.
 
levani dvalishvili
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still consider AJAX just an eyecandy, it does not realy bring anything seriouse on the table...
besides interactivity and that whole "milti-threaded request-response" bull.. that gives more headache to developers from the other perspectives of the application ...
I think tradeoff margin is quite thin
for what ajax can offer positive VS negative
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by levani dvalishvili:
I still consider AJAX just an eyecandy, it does not realy bring anything seriouse on the table...
besides interactivity and that whole "milti-threaded request-response" bull.. that gives more headache to developers from the other perspectives of the application ...
I think tradeoff margin is quite thin
for what ajax can offer positive VS negative


Until you actually get into an application that can benefit from it, then you may think this. Ajax is a beast if you do not know how to handle JavaScript! Books, tutorials, framewroks, and libraries are changing that.

I actually develop Ajax parts as my daily job and I am doing stuff that would not be possible in a traditional post back manner. The user experience of multiple post backs to update the page based on user selections would be rougher without it. I can build a more dynamic web page that adapts to the user instead of the user adapting to my web page.

A lot of people are afraid to adapt to a new technology. Yes you have to deal with that fact JavaScript can be disabled, but that tends to be 3-10% of surfers depending on where you ask.

If Ajax does not meet your needs than you do not have to use it. For those that need quick response times without having to render all of the controls on the page over and over and over it is for them.

Using ajax does not mean you have to reinvent your entire site. Start out with one little control and see how it performs. Then grow it out a bit. A double combo or type ahead suggest may change the way your user's see your site. I know a lot of people that are impressed with such a small change.

Eric
 
Linda Walters
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the risk of sounding like a "me too" post, I must say that I agree with Eric. I two make frequent (not necessarily daily) use of AJAX at in my work for a major vendor. When used properly (there's the rub!) it is great.

For instance, I recently had to implement a non-JSF tree widget for dynamically created user-defined forms. Since there was a priori limit on the amount of data that the tree could display, we had to have some way of loding the child nodes of a given node only when the end user expanded that node. AJAX was a perfect solution. Each node that the JavaScript got in XML contains an XML attribute that indicates the parameters to be POSTed to the server to get its immediate childern. When the node is expanded, this is POSTed to the server and we get back more XML and so on.
 
Linda Walters
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops! I just noticed a typo that changes the meaning of a statement in my last post. It should have read "there wasn't an a priori limit to the amount of data...

That makes more sense. I think.
 
John Fallows
Author
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajax provides a plugin-free communication channel between the browser and the web server, allowing more web application "intelligence" to be migrated to the browser for a more compelling user experience.

Of course, there are trade-offs when using Ajax to gain improved interactivity, such as increased complexity of writing web applications, graceful degradation for non-Ajax-capable clients, Section 508 accessibility, etc.

My co-author, Jonas Jacobi, and I have demonstrated that many of these issues with Ajax can be addressed by leveraging the standards-based server-side component model of JavaServer Faces.

We recommend encapsulation of Ajax functionality inside JSF component renderers, protecting the web application developer from the Ajax complexities. Dynamic JSF RenderKit switching can be used to degrade gracefully for non-Ajax-capable clients as well as to meet Section 508 accessibility requirements.

However, integration between JSF and Ajax requires significant effort if starting from scratch. So, as part of the book writing process, we decided to create 3 new open source projects on Java.net to provide common facilities to the JavaServer Faces Ajax component development community:

  • Weblets resource packaging
  • Mabon data fetch over Ajax
  • D� Delta-DOM rendering over Ajax


  • Kind Regards.
     
    Luis Ernesto
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    for one thing if you are at a job interiew you trow "i am proficient in ajax" here and there or in your resume you write, i have develop a few proyects using ajax and that will help a bit or not
     
    Pradeep bhatt
    Ranch Hand
    Posts: 8933
    Firefox Browser Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I think we cannot bookmark AJAX based applications?
     
    Eric Pascarello
    author
    Rancher
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Pradip Bhat:
    I think we cannot bookmark AJAX based applications?


    You can bookmark the application if you (the developer) spend the time to build in the functionality. Requires some work with hash and recognizing that on the server.

    Eric
     
    Gerardo Tasistro
    Ranch Hand
    Posts: 362
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Eric Pascarello:

    If Ajax does not meet your needs than you do not have to use it. For those that need quick response times without having to render all of the controls on the page over and over and over it is for them.



    Just to add to your post I'd add "render all of the controls half way down the page". I think that is a great feature of AJAX. Since you don't post you don't get kicked back to the top.

    I'm using AJAX in user information capture. It autocompletes based on zip code and other info. I really don't want to post to get the telephone area code half way down the page and then end up on the top. This is for a call center so you can realize that every move to the mouse, every scroll down and every field change counts.
     
    Gerardo Tasistro
    Ranch Hand
    Posts: 362
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Pradip Bhat:
    I think we cannot bookmark AJAX based applications?


    You can bookmark the application. After all it is only an URL. What you really mean is can we save the state of the AJAX based application. And that as Erik comments can be done too.

    You have to consider a couple of things here. Is your AJAX application a state machine or just pure combinational logic. In the later all you need to recover are the field values and the combinational logic will set itself through AJAX. An example of this is an AJAX driven select. If you set the controlling field the state of the select is automatically established.

    The situation of the state machine is more complicated. Since your current state is not only a function of the values in your fields (user input), but also the order in which this user set those values. In this case you will have internal javascript variables that will have to be persisted. For example a counter of how many times the user has pressed this or that button.

    So now you have not only to remember what the user has, but all the nifty little variables you keep inside you application. Now instead of only telling the server "Hey he just selected Georgia, remember that and give me the state population" you have to say than and "oh and my other variables are this button click 2 times, state changes 4, this that, etc".

    Obviously the more state variables the "heavier" the communication gets. This adds to latency. I suppose that to solve this issue you could save your state to a local cookie. But even this is complicated given AJAX, well asyncronous nature. You need to define transactions. When exactly you persist you state. A value change could trigger a series of AJAX calls that come back at unknown times. Each changing your current state. At one point you have to say ok this is it I'm saving my state variables should(in the very rare case) IE crash.
     
    Sandeep Chhabra
    Ranch Hand
    Posts: 340
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Whheeewwww..!!! :roll:

    Great knowledge sharing guys..
    Jonas Jacobi and John Fallows, it seems to be a great technology to learn...
    Thanks..
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!