Eddie Fann Guest
|
Posted: Sat Jan 10, 2004 7:17 pm Post subject: Re: JdbTable IllegalArgumentException: Row index out of rang |
|
|
Using JBuilder 6 Professional.
Well, I was having the same problem (with JDK 1.4 not JDK 1.3), so I looked
at your suggestion, and I looked at the source code of JdbTable. I found
that if I did the following while initializing a JdbTable
this.grdMain1.getSelectionModel().setValueIsAdjusting(true); // grdMain1
is a JdbTable.
then the problem went away.
Realize that I don't allow direct editing in a JdbTable. The user edits the
data in a dialog box filled with JdbTextField, etc. But the DataSet is the
same for the dialog components and the JdbTable.
I have no idea if this solution will introduce problems later on down the
line. . . .
"Gerald Turnquist" <Gerald.Turnquist (AT) sasktel (DOT) sk.ca> wrote
| Quote: | Well, I gave you folks a couple days to solve my problem for me and then
resorted to doing it myself
I tried the dbswing.jar from JB8 and it worked better but not quite
perfect.
It still had a problem if you selected the last row in the table, then the
'+' on the nav bar to insert, the blank row is inserted above the last
row.
If you then select the last row again (without having entered valid data
in
the new row above it) you still get an exception. I looked at the JdbTable
source and saw an attempted fix in the valueChanged() method that said:
if (selectedRow >= getRowCount()) { // This test is a fix for
149157.
Charles
selectedRow = getRowCount() - 1;
}
To get rid of the remaining problem described above, I copied the code
again
a little farther down in the method after the
dataSet.post() attempt:
if (dataSet.getRow() != selectedRow) {
ignoreNavigation = true;
try {
dataSet.goToRow(selectedRow);
if (selectedRow > 0) {
if (selectedRow >= getRowCount()) { // This test is needed
here too for 149157. Gerald
selectedRow = getRowCount() - 1;
}
setRowSelectionInterval(selectedRow, selectedRow);
}
}
"Gerald Turnquist" <Gerald.Turnquist (AT) sasktel (DOT) sk.ca> wrote in message
news:3e91e1df$1 (AT) newsgroups (DOT) borland.com...
My application is using a JdbTable with a QueryDataSet going against a
DB2
7.1 relational database. The user is allowed to add new rows by clicking
on
the + sign in a JdbNavToolBar but frequently gets a "Row index out of
range"
from the superclass JTable. It looks like in the
valueChanged(ListSelectionEvent e) method of the JdbTable it is getting
a
number from dataSet.getRow() one higher than the number of rows
displayed
in
the JdbTable, if the currently selected row is the last row in the
JdbTable.
It then tries to select that non-existent row. An exception is thrown,
snip
of the stack trace is below. Is this one of those 'known problems'
(hopefully with a 'known fix') or is it possible I'm doing something
dumb...no, that can't be it I did try DatabasePilot against the
same
database and if you launch it with a console (dbPilot.exe instead of the
default dbPilotW.exe) so you can see stack traces, you see it does the
same
thing.
JBuilder 7, Windows XP
Any help would be appreciated.
java.lang.IllegalArgumentException: Row index out of range
at javax.swing.JTable.boundRow(JTable.java:1256)
at javax.swing.JTable.setRowSelectionInterval(JTable.java:1279)
at com.borland.dbswing.JdbTable.valueChanged(JdbTable.java:2804)
at
javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionM
odel.java:187)
"Gerald Turnquist" <Gerald.Turnquist (AT) sasktel (DOT) sk.ca> wrote |
| Quote: | Well, I gave you folks a couple days to solve my problem for me and then
resorted to doing it myself
I tried the dbswing.jar from JB8 and it worked better but not quite
perfect.
It still had a problem if you selected the last row in the table, then the
'+' on the nav bar to insert, the blank row is inserted above the last
row.
If you then select the last row again (without having entered valid data
in
the new row above it) you still get an exception. I looked at the JdbTable
source and saw an attempted fix in the valueChanged() method that said:
if (selectedRow >= getRowCount()) { // This test is a fix for
149157.
Charles
selectedRow = getRowCount() - 1;
}
To get rid of the remaining problem described above, I copied the code
again
a little farther down in the method after the
dataSet.post() attempt:
if (dataSet.getRow() != selectedRow) {
ignoreNavigation = true;
try {
dataSet.goToRow(selectedRow);
if (selectedRow > 0) {
if (selectedRow >= getRowCount()) { // This test is needed
here too for 149157. Gerald
selectedRow = getRowCount() - 1;
}
setRowSelectionInterval(selectedRow, selectedRow);
}
}
"Gerald Turnquist" <Gerald.Turnquist (AT) sasktel (DOT) sk.ca> wrote in message
news:3e91e1df$1 (AT) newsgroups (DOT) borland.com...
My application is using a JdbTable with a QueryDataSet going against a
DB2
7.1 relational database. The user is allowed to add new rows by clicking
on
the + sign in a JdbNavToolBar but frequently gets a "Row index out of
range"
from the superclass JTable. It looks like in the
valueChanged(ListSelectionEvent e) method of the JdbTable it is getting
a
number from dataSet.getRow() one higher than the number of rows
displayed
in
the JdbTable, if the currently selected row is the last row in the
JdbTable.
It then tries to select that non-existent row. An exception is thrown,
snip
of the stack trace is below. Is this one of those 'known problems'
(hopefully with a 'known fix') or is it possible I'm doing something
dumb...no, that can't be it I did try DatabasePilot against the
same
database and if you launch it with a console (dbPilot.exe instead of the
default dbPilotW.exe) so you can see stack traces, you see it does the
same
thing.
JBuilder 7, Windows XP
Any help would be appreciated.
java.lang.IllegalArgumentException: Row index out of range
at javax.swing.JTable.boundRow(JTable.java:1256)
at javax.swing.JTable.setRowSelectionInterval(JTable.java:1279)
at com.borland.dbswing.JdbTable.valueChanged(JdbTable.java:2804)
at
javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionM
odel.java:187)
|
|
|