Archive for the ‘Ajax’ Category

Pagination & sorting in jsp’s with the displaytag taglib & spring

Friday, February 13th, 2009

I hate writing pagination code. Infact I hate it so much, I try not to paginate my lists at all. ( I know, i know, very bad on my part) :) . Writing pagination code totally destroys the code reuse in an application, developers generally just copy paste the very same pagination code all over the place over and over again. Not to mention decorating such pagination displays is a pain in the ass as well. So while searching for a more concrete solution to my problem I stumbled upon displaytag.

Display tag is by far the most comprehensive pagination solution that I have ever come across. Not only is the library extremely stable, (more…)

Ajax based form validation with spring and dwr

Tuesday, February 10th, 2009

Form validation is an integral part of any web application. While most developers rely on client side validations, the good ones always perform server side validations as well before accepting any data. You never know what kind of a malicious attack/vulnerability might be exposed if you don’t validate all data. Submitting, validating and then returning to the form again (if errors exist) is the normal flow but we can assist the user further by validating his data immediately. This form of validating user data is in no way supposed to substitute server side validation but only supposed to help the user and make your interface a little more snazzy. :) (more…)

Dynamic dropdown (Country/state) with dwr & spring

Monday, February 9th, 2009

In my earlier article I had detailed how to get DWR working with spring. Once you get that done, how exactly do you use it? Even though DWR provides a very powerful debugging page, a real-world example never hurts. :)

I’ll construct a simple page which will present the user with a list of countries (populated via DWR on body load). Once the user selects a country (more…)

Dwr + Spring integration example

Saturday, February 7th, 2009

I like DWR, it’s a very strong framework for enriching your simple web application with ajax. It’s particularly useful for java developers because no one likes to write javascript to make XMLHttpRequest’s to call the server, parse the response and then set stuff in your jsp so that the response is displayed in a proper manner. You can effectively expose your entire class simply by defining it’s methods in your dwr.xml and then writing converter’s for your objects. The util.js that comes with dwr is very useful too even if you aren’t using dwr, it provides a lot of helpful methods to do stuff in javascript.

The debug page is probably what I loved the most about dwr. It lists out what classes have been exposed including their methods in a very simple manner. You can immediately test if you have configured dwr and if it’s working properly. You can also test out your exposed methods, with and without parameters, and see their responses. It’s lovely and I wish more applications would do this.

Running DWR with spring however is a (more…)