The Source for Java Technology Collaboration
User: Password:



Greg Murray's Blog

J2EE Archives


Realtime Form Validation with AJAX

Posted by gmurray71 on April 05, 2006 at 01:01 PM | Permalink | Comments (0)

When validating form field entries using AJAX as described in the article Realtime Form Validation Using AJAX there are additional issues that come to mind. These include:
  • Do I have to validate a single form field? Not necessarily. The article was written to show the simplest use case. You could also do validation based on any combination of form data. You should not consider this solution limited to input text fields as well.
  • What JavaScript event do I use to validate on? A validation using AJAX interactions on each keystroke could spell trouble for your server as the number of users increase. Consider combining timer-based events along with keystrokes for those of us that type really fast.
  • Should I use a GET or a POST with my XmlHttpRequests? A validation request does not change state on the server so a GET is appropriate for most cases. That said, make sure that you call the built in JavaScript encodeURIComponent() on all the form parameters you are sending as it will format them in a HTTP friendly way and is internationalization friendly. Consider using the HTTP POST method in cases where you are validating large amounts of data as not all web browsers support URLs that exceed 2,083 characters.
  • Should I use XML or text for the responses? If you do keep in mind the server resources that will be used to parse and generate the XML. Simple validation could be done with a simple text string. If you want to provide more information consider using JSON.

What issues do you face using AJAX to validate form data?



Happy 1st Birthday AJAX!

Posted by gmurray71 on February 17, 2006 at 07:00 PM | Permalink | Comments (3)

A year ago I swore I would never use the term AJAX (that lasted about 3 days) as it brought to mind cleaning my sink. A year later I have to say AJAX has made the world a better place and looks to make an even brighter future.

Where has AJAX come in its first year?

  • AJAX is almost easy enough for a 1 year old - When AJAX emerged there was a lot of FUD comparing AJAX to rocket science. At Sun have shown the any Java developer can easily use AJAX, whether it be from a simple web page attached to a Servlet as described in this tech tip or a JSF component in a tool such as Creator that does all the heavy lifting.
  • Everybody loves AJAX - While many companies would not touch a 1 year old technology with a 10 foot cattle prod, AJAX is different. Like any cute baby everyone wants to embrace AJAX. Over the past year many companies have deployed AJAX enabled applications and services. Others like Sun are enabling there tools and technologies.
  • AJAX is making lots of friends - Like any active 1 year old AJAX is making many friends. AJAX does not favor any platform or technology. It gets along with everyone. As I speak with developer from all walks of life (Java, .Net, RoR, and PHP) I can speak the same language though to a non-tech savvy passer by this may appear to be a 1 year old's gibberish.
  • AJAX learned to stand on its own - Not bad for a 1 year old! During the first year of existence many frameworks have begun to support AJAX. New client and server frameworks have emerged and every day something new appears.
  • AJAX is still growing - Like any 1 year old AJAX is growing up fast. New ideas and techniques are being developed and refined on a daily basis. Maybe AJAX will learn to talk in something other than XML or JSON during it's second year?

While much more could be said about this 1 year old I'll keep this short. We should all take a moment to reflect where AJAX have been in the last year and where it's going in the year to come. Happy Birthday AJAX!



AJAX FAQ for the Java Developer

Posted by gmurray71 on October 14, 2005 at 03:10 PM | Permalink | 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?



Rich Web Applications with AJAX

Posted by gmurray71 on April 25, 2005 at 02:44 PM | Permalink | Comments (4)

There has been much talk about rich web applications in recent days. When I first encountered Asynchronous JavaScript and XML (AJAX) it was still being called web remoting or remote scripting. After seeing some pretty cool applications being developed by some well known companies I took myself to task and wrote a few rich web applications using AJAX with J2EE technologies supporting the server-side logic. I found that AJAX can really make a better web applications that can do some amazing things such as simulated server-side pushes using polling, in-page form validation using server-side validation logic, and auto-completion all without page refreshes. The document Asynchronous JavaScript and XML (AJAX) with Java 2 Enterprise Edition details the AJAX interaction model in much more detail and elaborates on some of the usecases for AJAX.

Using AJAX does not come for free though. You must accept and embrace JavaScript and CSS, assume that it is available and enabled on the client, and invest time making sure the applications behave the same across browsers. This sounds simple enough but from my experience I spend much more time developing the JavaScript and CSS than I do the server-side logic. In time this will become easier as frameworks embrace/emerge that will support AJAX.

Where are we at today?

Currently, I am responsible for the servlet specification and I am a former member of the BluePrints team. The BluePrints team and I are using the Java BluePrints Solutions Catalog to showcase AJAX with J2EE technologies. There are currently four solutions for using AJAX with J2EE in the Java BluePrints Solutions Catalog. Each solution includes a problem/solution statement, a design document, and working code.

Please download the Java BluePrints Solutions Catalog (a set of web applications including the documentation) or view the documentation online at https://bpcatalog.dev.java.net/nonav/ajax/index.html. We plan to actively increase the number of solutions in the catalog so please stay tuned.





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