views:

61

answers:

2

Hello

I have a database table for log messages and at any time there can be inserted new rows. I want to show them in grid and when you scroll down I want to request more rows form this table (server side) but without to be affected from new added rows. The new rows only have to be visible if I refresh the whole grid.

I'm not sure how can I request rows in a range (from, to) using JDBC. I think there is no portable (across deferent databases) SQL query to do this? (I'm using MYSQL)

I think that after reading first page of this table I have to send to the client side the Max Id from log table and after that request new rows using this Max Id as parameter in SQL (WHERE id <= MAXID) but I'm not sure how I can pass this parameter from server to client and back using RestDateSource?

Do you have any better ideas how I can make this?

P.S. I'm using LGPL SmartGWT version and using my own servlets for server side.

A: 

SmartGWT Pro and better do this automatically. Even if you don't want to use Pro, you can download the evaluation (smartclient.com/builds) and watch the server-side console, where the SQL queries are logged.

Charles Kendrick
I saw that they are using LIMIT (SQL) but they still have the problem with newly concurent inserted rows. http://www.stackoverflow.com.s3.amazonaws.com/Concurent%20Insert.png
ju
+1  A: 

Here is what I would do; I imagine that you either have a growing-number ID or a timestamp for each of your rows.

Before you start querying for data, you call a webservice to query the current id (eg last line insterted is 12345).

Then you add a Criteria object to your datasource that says "rowId <= 12345". At this point, you can use the grid freely - paging, sorting, etc will work automatically as new rows will automatically be excluded.

(Or if you use a personalized datasource and not the default RESTdataSource, you basically do the same thing without using Criteria explicitly).

Lenz
That's exactly what i made and it works great :)
ju
And by the way, how can I make "less or equal" crieteria?
ju
I'd go for "rowId < (12345+1) "
Lenz