Table updates

0 views
Skip to first unread message

Chris Lowe

unread,
Feb 8, 2009, 7:16:04 AM2/8/09
to gwt-m...@googlegroups.com
Hi,

I'm looking at using a Table component to display a table model that
updates occasionally. To test the component I created a table with an
empty data model and later on (after an RPC callback) I'm adding rows
to my data model. However the table does not reflect the changes. In
my data model I'm calling fireTableDataChanged() which ultimately
calls Table.tableChanged(), but this method appears missing an
implementation:

public void tableChanged(TableModelEvent event) {
if (event == null || event.getFirstRow() == TableModelEvent.ALL_ROWS) {
table.getDataTable().deselectAllRows();

// TODO

return;
}

if (event.getType() == TableModelEvent.Type.INSERT) {

} else if (event.getType() == TableModelEvent.Type.DELETE) {

} else {

}

Is there anything I can do to make this work?

Cheers,

Chris.


public static class LogSummaryPanel extends Composite {

private final Table<String[]> table;
private final StringArrayTableModel tableModel;

public LogSummaryPanel() {

final LayoutPanel vBox = new LayoutPanel(new BoxLayout(Orientation.VERTICAL));

vBox.setPadding(0);

final String[] columnNames = {
"Col1", "Col2", "Col3", "Col4", "Col5"
};

tableModel = new StringArrayTableModel(new String[0][5]);

table = new Table<String[]>(tableModel, new
DefaultTableColumnModel<String[]>(columnNames));

table.setPageSize(2);

final PagingOptions pagingOptions = new PagingOptions(table);

vBox.add(table, new BoxLayoutData(FillStyle.BOTH));
vBox.add(pagingOptions);

...
}


public void updateLog() {
Object[][] dataObj = new Object[][] {
{ "Mary", "Campione", "Snowboarding", new Integer(5), new
Boolean(false)},
{"Alison", "Huml", "Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath", "Knitting", new Integer(2), new
Boolean(false)},
{"Sharon", "Zakhour", "Speed reading", new Integer(20),
new Boolean(true)},
{"Philip", "Milne", "Pool", new Integer(10), new Boolean(false)}
};

String[][] data = new String[dataObj.length][5];

int i, j;

for (i = 0; i < dataObj.length; i++) {
for (j = 0; j < 5; j++) {
data[i][j] = dataObj[i][j].toString();
}
}

tableModel.setData(data);
}

}


public class StringArrayTableModel extends AbstractTableModel<String[]> {

private String[][] data;


public StringArrayTableModel(final String[][] data) {
this.data = data;
}

public int getRowCount() {
return data.length;
}

public void setData(final String[][] data) {
this.data = data;

fireTableDataChanged();
}

public Object getValueAt(final int rowIndex, final int columnIndex) {
return data[rowIndex][columnIndex];
}

public void setValueAt(Object value, int rowIndex, int columnIndex) {

data[rowIndex][columnIndex] = value.toString();

fireTableCellUpdated(rowIndex, columnIndex);
}

}

G. Georgopoulos

unread,
Feb 8, 2009, 10:57:08 AM2/8/09
to gwt-m...@googlegroups.com
Hi Chris,

yes, filling a Table widget after an RPC is not ready. It works only for
ListBox so far:

http://69.20.122.77/gwt-mosaic-current/Showcase.html#CwListBoxBinding

but all those widgets need still work.

Its better for you to use ScrollTable or the PagingScrollTable from GWT
Incubator:

http://69.20.122.77/gwt-mosaic-current/Showcase.html#CwScrollTable
http://69.20.122.77/gwt-mosaic-current/Showcase.html#CwPagingScrollTable

both:

http://gwt-mosaic.googlecode.com/svn/tags/0.1.8/doc/org/gwt/mosaic/ui/client/table/ScrollTable.html

and

http://gwt-mosaic.googlecode.com/svn/tags/0.1.8/doc/org/gwt/mosaic/ui/client/table/PagingScrollTable.html

are modified versions of Scrolltable and PagingScrollTable and use a
LayoutPanel, but you can use also the GWT Incubator gen2 tables. Soon I
will modify them to use a LayoutPanel.

Kind Regards,
George.

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "gwt-mosaic" group.
> To post to this group, send email to gwt-m...@googlegroups.com
> To unsubscribe from this group, send email to gwt-mosaic+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/gwt-mosaic?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>
>

Chris Lowe

unread,
Feb 8, 2009, 11:22:49 AM2/8/09
to gwt-m...@googlegroups.com
Thanks George, I'll take a look.

2009/2/8 G. Georgopoulos <georgopoul...@gmail.com>:

Chris Lowe

unread,
Feb 11, 2009, 1:39:07 PM2/11/09
to gwt-m...@googlegroups.com
Hi George,

I sort of have a PagingScrollTable working now.  In fact, in hosted mode it's working fine.  However when I compile to final code the table body doesn't render!  I've added some logging trace to my code and I can see the right callbacks are being invoked and even cell renderers are called as expected.  The table PageOptions component also works fine and shows the correct number of pages.  I've tried both IE7 and FF3.

I'm not sure where to begin debugging something like this, I don't suppose anyone has seen this before and could offer some advice on where to start?

Cheers,

Chris.

G. Georgopoulos

unread,
Feb 11, 2009, 1:57:16 PM2/11/09
to gwt-m...@googlegroups.com
Hi Chris,

if its possible please send me code to test. I don't know what exactly
the problem is.

George.

Chris Lowe wrote:
> Hi George,
>
> I sort of have a PagingScrollTable working now. In fact, in hosted
> mode it's working fine. However when I compile to final code the
> table body doesn't render! I've added some logging trace to my code
> and I can see the right callbacks are being invoked and even cell
> renderers are called as expected. The table PageOptions component
> also works fine and shows the correct number of pages. I've tried
> both IE7 and FF3.
>
> I'm not sure where to begin debugging something like this, I don't
> suppose anyone has seen this before and could offer some advice on
> where to start?
>
> Cheers,
>
> Chris.
>

> 2009/2/8 Chris Lowe <chris.lowe.uk <http://chris.lowe.uk>@gmail.com
> <http://gmail.com>>


>
> Thanks George, I'll take a look.
>
> 2009/2/8 G. Georgopoulos <georgopoul...@gmail.com

> <mailto:georgopoul...@gmail.com>>:

Chris Lowe

unread,
Feb 12, 2009, 5:17:01 AM2/12/09
to gwt-m...@googlegroups.com
Morning George,

Thanks for the reply.  I've solved the issue now.  I was originally using the widgetideas version of PagingScrollTable as I'd started off with the mosaic example code for the CwPagingScrollTable and worked back from there. That's when I saw the strange behaviour. Shortly after posting this message I rewrote my code using the gen2 versions. Initially this appeared to put me in a worse position as both the table header and body were now hidden in hosted mode and deployed modes. They were definitely on the page somewhere because I could select the whole page and paste into notepad and I could see the content. I eventually tracked the problem down to the container component that I was using for the table. Originally I was using this:

final LayoutPanel vBox = new LayoutPanel(new BoxLayout(Orientation.VERTICAL));

vBox.setPadding(0);

// (create scroll table and paging options)

vBox.add(scrollTable, new BoxLayoutData(FillStyle.BOTH));
vBox.add(pagingOptions);

By switching to a FlexTable the component now renders fine.  I can only guess that this was also something to do with my initial problem although I've no idea why it would work in one mode and not the other.

Cheers,

Chris.


2009/2/11 G. Georgopoulos <georgopoul...@gmail.com>
Reply all
Reply to author
Forward
0 new messages