The form element in html was a key component of dynamic content on the web. If you wanted to change something on the server with a user action on the Browser, this was the way to go. Well it still is quite popular. Click on a hyperlink / click of a button was the main interaction mechanism long back. Things are no longer the same.
The advent of Asynchronous Communication with the server (aka AJAX) has opened up the list of options I have. To list a few you see so often in the web.
Star Ratings.
Digg / Bury.
Tabbed pages.
Web based chat.
Auto Save.
Auto Complete.
....
These interactions with the server do not rely on form submit. There are things that happen behind the scenes as well. If you read a article, The author of the article can find out how much time you spent on the page. Also he can find out if you did scroll down to read the entire article. He just managed to capture something important about your behaviour without your sending it to him. Scary huh!
I was designing an Web UI for an application recently (this was after i became comfortable with the ajax technology) and I did spent some time trying to find out a good way to place the form element on my page. In simple cases it was pretty straight forward. In more complex scenario i found there was no neat place. That really set me into some thinking mode. What is that the form element really gives me.
1) It can get the data from a bunch of related fields and send it to the server.
2) I have a place to specify the URL where this data needs to go.
Have you used hidden fields in form? Didn't it seem kinda ugly hack. People have misused it. I know a couple of them. Don't want to list it out, cause people knowing me will find out what I am talking about ;)
Ok, that was a thread that just spawned off. Lets get back to the main thing. What can I do instead of using a form?
A small javascript method can achieve the same with a lot more flexibility.
1) I can determine the exact thing that gets sent to the server.
2) I can determine where it goes, The same information I can send to different URL's based on the user choice. (remember the hidden field called action/type! :) )
3) I am not limited to GET/POST. I can follow the restful http paradigm to a great extent. I can set the method as DELETE / PUT as well.
This things will make sense if you have already commited to the AJAX way of building an applications. Most of the Java Web frameworks out there still have Form as an integral part of their framework. Capturing the information in databean and passing it around.
I tried it out, It works! More...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment