The Source for Java Technology Collaboration
User: Password:



Greg Murray

Greg Murray's Blog

AJAX FAQ for the Java Developer

Posted by gmurray71 on October 14, 2005 at 03:10 PM | Comments (8)

In the land where Java flows freely I have encountered many that are not familiar with AJAX and ask many of the same questions. I put together this FAQ with developers that use Java and Java Enterprise Edition in mind.

See the AJAX FAQ for the Java Developer.

Some of the questions I have addressed include:

  1. Should I consider AJAX?
  2. Does AJAX work with Java?
  3. Won't my framework provide me with AJAX?
  4. Where should I start?
  5. What do I need to know?
  6. Do I really need to learn JavaScript?
  7. What JavaScript Libraries and Frameworks are out there to assist a Java developer?
  8. Should I use XML or text, JavaScript, or HTML as a return type?
  9. Are there usability issues with AJAX?
  10. How do I test JavaScript?
  11. Should I use an HTTP GET or POST for my AJAX calls?
  12. How do I provide internationalized AJAX interactions?
  13. How do I handle concurrent AJAX requests?
  14. What do I do on the server to interact with an AJAX client?
  15. Where do I store state with an AJAX client?
  16. How do I submit a form or a part of a form without a page refresh?
  17. Is the server or the client in control?
  18. Are there any security issues with AJAX?
  19. When do I use a synchronous versus a asynchronous request?
  20. What about applets and plugins?
  21. How do I handle the back and forward buttons?
  22. How do I send an image using AJAX?
  23. How do I create a thread to do AJAX polling?

These questions are not all Java related but are common things a web developer starting with AJAX may ask.

What questions would you like addressed?


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Thanks for the FAQ. The suggestion of using JSF to simplify AJAX is one that keeps comming back. From using some of the AJAX libraries I don't find that this abstraction is necessary. Some of the libs make it very easy to attach behaviour to a standard HTML DOM element, and the higher level abstractions like backbase are server agnostic (PHP, J2EE, .net).

    I see AJAX reducing the need to even consider using JSF.

    Posted by: tcowan on October 17, 2005 at 06:47 AM

  • Excellent stuff Greg. This is *really* useful.

    Posted by: jonbruce on October 17, 2005 at 08:26 AM

  • I would like to see testing AJAX addressed. Yes, I realize Question #10 asks about testing, but the answer is all about debugging. I want to know how to write automated tests for my apps. Is there a testing framework -- AJAXUnit or something like that -- out there?

    Thanks for all the information.

    Posted by: rufus on October 17, 2005 at 01:23 PM

  • The selling point for JSF based components is that they allow you to encapsulate a set of server side logic and the client rendering. Whether the component render html elements backed by a higher level widget abstraction such as those in Dojo Widgets is something we are still looking into. I will say more as I have a chance to develop a few.

    Automated AJAX testing is something that I have not spent much time with yet. Because many AJAX like user gestures would require more extensive framework I think it's going to be some time before truly automated testing frameworks and tools can be developed. How could you test for example drag and drop from something like HttpUnit?

    Posted by: gmurray71 on October 17, 2005 at 08:39 PM

  • Nice list! Thanks for putting the work in Greg :D

    Its a shame this can't be 'stickied'. I hope I can find it when I need it.

    Some guys I worked with in NZ had the nice idea of mixing Ajax and portlets, which was a nice trick.

    Posted by: rickcarson on October 18, 2005 at 04:13 AM

  • @rufus - In OSX you can send Safari applescript messages to execute arbitrary Javascript code, so you could get most of the way to a set of automated tests for your Javascript fairly easily. It would be interesting to see if HttpUnit and (the other one, WebUnit???) allow executing of Javascript (I know at least one of them has a fairly sophisticated emulation of a browser, not sure if it is sophisticated enough though).

    In case you're interested, the relevant applescript is:
    tell application "Safari"
    do JavaScript "document.getElementById('form1').submit();" in the first document
    end tell

    If you have say for instance a Javascript function called defunct you could do this:
    tell application "Safari"
    do JavaScript "defunct();" in the first document
    end tell

    You can put more than one do Javascript command in between the tell and end tell, and you can (in theory) make it so you can execute the script by double clicking on it (I haven't figured out how to do that, I haven't needed it yet).
    You can also use applescript to point it at a particular page, eg:

    set testfunc to "
    {
    document.f.q.value = 'ptang';
    document.f.btnI.click();
    }"
    tell application "Safari"
    open document
    set the URL of the front document to "Http://www.google.com"
    -- wait three seconds
    delay 3
    do JavaScript testfunc in the first document
    end tell
    etc.

    Posted by: rickcarson on October 18, 2005 at 07:11 AM

  • Excellent Stuff !!! Thanks Greg for this work, Thanks also to http://www.ajaxgoals.com for referring to this great post.

    Posted by: johnajax on October 18, 2005 at 11:58 AM

  • Great article Greg! May be you should have split it to two parts.

    Posted by: saro28 on February 25, 2006 at 12:59 PM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds