|
|
ListTableModel NullPointerException
Hi all.
I'm new user of Spring RCP and i try to used ListTableModel.
I have implemented exactly the example of the wiki. Like this:Code: List rows = new ArrayList(); rows.add(Arrays.asList(quot;000001quot;, quot;Applequot;)); rows.add(Arrays.asList(quot;000002quot;, quot;Sunquot;)); rows.add(Arrays.asList(quot;000002quot;, quot;IBMquot;));
ListTableModel tableModel = new ListTableModel(rows) {
protected Class[] createColumnClasses() { return new Class[]{String.class, String.class};}
protected String[] createColumnNames() { return new String[]{quot;Numberquot;, quot;Namequot;};} };
JTable jTableLeftUp = TableUtils.createStandardSortableTable(tableModel);
And when i access to my view, i have a null Pointer execption.Code:
java.lang.IllegalStateException: Application start thrown an exception: null at org..richclient.application.ApplicationLauncher.launchMyRichClient(ApplicationLauncher.java:316) at org..richclient.application.ApplicationLauncher.lt;initgt;(ApplicationLauncher.java:159) at fr.jcronload.SimpleApp.main(SimpleApp.java:77)
Caused by: java.lang.NullPointerException at org..richclient.table.BaseTableModel.getColumnCount(BaseTableModel.java:152)
Here's a little of my POM configuration.
Code: lt;propertiesgt; lt;springrich.versiongt;1.0.0lt;/springrich.versiongt; lt;spring.versiongt;2.5.1lt;/spring.versiongt; lt;/propertiesgt; ... lt;dependencygt;lt;groupIdgt;org..richclientlt;/groupIdgt;lt;artifactIdgt;spring-richclient-supportlt;/artifactIdgt;lt;versiongt;${springrich.version}lt;/versiongt; lt;/dependencygt; ...
Thanks.
If you look closely to the code of BaseTableModel, you'll soon find out why:Code:
public int getColumnCount() { return columnNames.length; }
columnNames is filled when calling createColumnInfo(), which in turn is only called upon by setRowNumbers(boolean).
So you can do one of the following:
1) create a subclass of ListTableModel, which exposes createColumnInfo(), and call this method after creating the ListTableModel (it's standard protected)
2) override the method getColumnCount();
3) call setRowNumbers(false)
Kind regards,
Lieven
Thanks for quick and quality answer.
Its works perfect with solution 3.
Regards, |
|