Panasonic Youth

calling your data layer via Ajax (jsquery) - a bad idea?

Saw on ajaxian a blurb about jsquery. It is basically a library to grab data directly from your server side JDBC/ORM layer and expose it to your pages as a javascript array that follows the ResultSet interface.

I’m not sure of the wisdom of doing something like this. This directly couples your view layer code to your data layer code. Even if you just want a “quick and dirty” solution and don’t care too much about MVC, I would rather write my JDBC calls in a seperate data layer and test that independantly, and then remote the model objects via DWR. If you really want to be dirty you could just return your dom structure or XML from your servlet and not worry about any “true” model objects. But why deal with the result set interface on the javascript side? If you go with jsquery, where do you clean or strip your data? How do you reuse that JDBC/ORM call in other places without violating DRY? Maybe I’m missing something here…enlighten me.