I'm a little bit stucked right now and I hope someone can help me with my problem.
I'm getting a ResultSet
from a SQL Query and I want to use GWT CellTable
for displaying the content of my ResultSet
dynamically based on the ResultSet
. I need this for displaying the whole content of an mySQL-Table and I want to make this dynamically so I can create any table and the CellTable
will be generated dynamicaly.
Has someone an idea for an convenient way?
I wouldn't recommend this approach as the drawbacks cleary outweigh the benefits.
Here is the simplest approach I can think of and it only works with one type of column (Text column):
You have to send your data, that you want to display in a generic dynamic CellTable
, as a List
of Map
objects.
When you receiver the data on the client you have to dynamically construct the columns in the CellTable
. You can do this by looking at the keys of the first Map
object in your List.
You probably will have to implement a custom Column
to which you pass the key
of the corresponding field in your Map
object. In the getValue()
method of your custom Column
you will return the corresponding field of your Map
objects using the key
you passed in.
You can then use a TextCell to render the method.
Of course if you want to support different kind of types (Number, Date, etc) it get's more complicated.