AggregateTable(Model) questions

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

AggregateTable(Model) questions

Postby jfilho036 » Wed Sep 10, 2008 7:33 am

Hello jide,
I am a newbie to jide and I have questions related to AggregateTable.
1) Should the AggregateTableModel automatically change whenever the underlying actual table model changes due to new rows/columns? I did a small test where I create a AggregateTable with a DefaultTableModel, and whenever new rows/columns are inserted to DefaultTableModel, nothing happens to AggregateTableModel. What should I do to ensure AggregateTableModel refreshes after underlying TableModel changes?
2) While doing this test, I passed an empty DefaultTableModel arg (0 rows, 0 columns) to AggregateTable because I wanted to add data asynchronously. However AggregateTable generated the following exception. (Maybe because it requires a TableModel with at least 1 column?)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.jidesoft.pivot.AggregateTableModel.setAggregatedColumns(Unknown Source)
at com.jidesoft.pivot.AggregateTableModel.<init>(Unknown Source)
at com.jidesoft.pivot.AggregateTableModel.<init>(Unknown Source)
at com.jidesoft.pivot.AggregateTable.<init>(Unknown Source)

Thanks for your help,

Jose
jfilho036
 
Posts: 13
Joined: Mon Aug 25, 2008 8:30 am

Re: AggregateTable(Model) questions

Postby JIDE Support » Wed Sep 10, 2008 9:52 am

1. It should update automatically. Do you call DefaultTableModel#addRow or DefaultTableModel#getDataVector().add. The former will fire the table model event which we depend on. It will work. The latter won't work as no event is fired.
2. We always aggregate the first column. That's why it got NPE when the table model is empty. I will see if we can fix it. If the table model is empty, we just don't aggregate.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: AggregateTable(Model) questions

Postby jfilho036 » Wed Sep 10, 2008 11:39 am

Thanks for your reply.

I still have issues with 1). Here is what happens in my demo code:
a) If I add columns to DeafultTableModel by calling defaultTableModel.addColumn(), AggregateTable(Model) does not update itself. Here is my debug stmts for every addColumn call (columnCount of AggregateTableModel does not change):
Adding data to DefaultTableModel
Default model cols 2,rows 2
Agg model cols 1,rows 2
Adding data to DefaultTableModel
Default model cols 3,rows 2
Agg model cols 1,rows 2
Adding data to DefaultTableModel
Default model cols 4,rows 2
Agg model cols 1,rows 2
...

b) If I add rows to DefaultTableModel by calling defaultTableModel.addRow(), AggregateTable(Model) shows new added rows. Here is my debug stmts for every addColumn call (rowCount of AggregateTableModel does change):
Adding data to DefaultTableModel
Default model cols 1,rows 2
Agg model cols 1,rows 2
Adding data to DefaultTableModel
Default model cols 1,rows 3
Agg model cols 1,rows 3
Adding data to DefaultTableModel
Default model cols 1,rows 4
Agg model cols 1,rows 4
...

So it seems that AggregateTableModel refreshes when adding rows, but it does not refresh when adding columns. Any thoughts about it? Your help is greatly appreciated.

Thanks a lot!!!

Jose
jfilho036
 
Posts: 13
Joined: Mon Aug 25, 2008 8:30 am

Re: AggregateTable(Model) questions

Postby JIDE Support » Wed Sep 10, 2008 12:03 pm

I will take a look. For now, you can call AggregateTableModel#setAggregate(...) then aggregate() again when you add a column.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: AggregateTable(Model) questions

Postby jfilho036 » Wed Sep 10, 2008 1:30 pm

Dude,

Your workaround works! And I just had to call aggTableModel.setAggregatedColumns(). No need for aggTableModel.aggregate()

It would be great if this call was not necessary though.

Thanks!

Jose
jfilho036
 
Posts: 13
Joined: Mon Aug 25, 2008 8:30 am

Re: AggregateTable(Model) questions

Postby JIDE Support » Tue Sep 30, 2008 8:15 am

Just so you know, 2.4.0 release should fix this. Please verify it and let us know.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 14 guests