Skip to main content

How to fill a dojo.table from SQL query?

3 replies [Last post]
wholladay
Offline
Joined: 2004-01-20

Sorry if this is a dumb question. I am very new to Javascript, Dojo, and jMaki. I want to fill in a table by executing a SQL query. I've seen mention of the "service" tag for dojo.table. So I thought I could do something like this:

For a first try, I just put this code in the MyTable.jsp file. The next step would be to replace it with an actual query.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

{columns: { 'title' : 'Title', 'author':'Author', 'isbn': 'ISBN #', 'description':'Description'},
rows:[
['JavaScript 101', 'Lu Sckrepter','4412', 'Interesting read.'],
['Ajax with Java', 'Jean Bean','4413', 'Awsome book about ajax.']
]
}

However, when I do this nothing seems to show up. I'm not sure what the path to the jsp file should be.

I also noticed references to a JSON file. I don't know anything about JSON. Can I dynamically create a JSON file and then feed that to the table?

Anyway, I'm starting to ramble. What is the best way to get dynamic data into a table?

Thanks in advance,
Walter

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
wholladay
Offline
Joined: 2004-01-20

gMurray71,

That did the trick! Thank you so much, and thanks for responding so quickly.

In an unrelated note:
I was at the WEBBuilder2.0 conference where jMaki was shown (perhaps it was you that demo'd it?). Anyway, I heard several people mention that using a portal and portlets is probably not a good idea. The only reasoning I've heard is because the portal refreshes all of the portlets whenever something changes.
My team seams to be headed down the path of using a portal and portlets to create something similar to the Google and Yahoo customizable home page. I was wondering if you had any advice on why portlets would be a good or a bad way to go. If you know of any authoritative articles, that would be great too.

Thanks again,
Walter

gmurray71
Offline
Joined: 2003-07-31

That was me at Web Builder :-)

Portlets are good because the provide a structured standards based way of building applications. They are especially good if you are developing applications with big teams where you need a more structured approach.
Also you are going to support a widget range of browsers because the Porlets can manage views on the server and re-render then on each request for older browsers.

The Portlet spec is moving in a direction for supporting Ajax.

See this blog by Greg Ziebold who is working on incorporating Ajax into Portlets.

http://developers.sun.com/prodtech/portalserver/reference/techart/ajax-p...

The jMaki Injector though its done all in JavaScript. Basically the Injector is a JavaScript class that lets you take content from any given page in your domain and inject it (including scripts and styles) into a div of a page based on an event or you can see it used with container widgets such as the Dojo and Yahoo tabbed views. It's more light way but it's also using Ajax so you don't get the same benefits of having the structure and the graceful degradation that portlets can provide. It's also developing technology.

I've finally gone out and documented it at:

https://ajax.dev.java.net/injector.html

Both approaches are good. If you are planning on having a heavily scripted front end consider the jMaki style approach. Make sure to read the drawbacks at the bottom as they will apply even if you don't use the Injector API and choose to write it yourself in JavaScript.

If you are looking at something that will work with older browsers, is more structured in it's API and provides that graceful degradation portlets may be better for you.

gmurray71
Offline
Joined: 2003-07-31

For starters try removing the DOCTYPE from the top. The data is in JSON format ant the Doctype will cause an error.

you should also not set the content type to text/html. If you are going to set the content type try:

<%@page contentType="text/json"%>

We hope to have an example of this soon in the tutorials.