Posts Tagged ‘dwr’

Configuring DWR 3.0 with spring using annotations

Saturday, February 21st, 2009

I’m a fan of the spring framework and I have recently become a fan of DWR as well. Both of them together are just unstoppable, they take ajax and bean exposure through javascript to a new level. I have written about my experiences integrating the two and about validating forms using ajax. I’d advise you to read at least the integration article before continuing.

Using annotations to configure the spring container is a very useful feature, a majority of developers prefer to use annotations rather than XML files. However, annotation driven configuration of DWR through spring was not possible in older versions of DWR. The new version however, allows such configuration and with ease I might add. You can now use DWR with spring with almost no configuration in your XML files(a little bit of configuration is required but it doesn’t go beyond 10 lines or so). The best part however is that you don’t need to configure a seperate servlet for DWR at all, all calls to dwr can be routed through the spring dispatcher servlet which helps cut down configuration even more. (more…)

Writing custom UserDetailsService for spring security

Wednesday, February 11th, 2009

I wish spring security would work on their documentation and tell people how easy it is to implement a custom service for loading user details. You don’t HAVE to use JDBC to do that, you can write your very own hibernate, toplink or whatever DAO to do just that. It’s important to realise that spring-security does not send your password to the database ever. Instead it loads a user’s details and then compares it’s password internally before validating the user and granting it access to internal pages. (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…)