craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > General QuickTable Support/Help Post New Topic   Post A Reply
after insert(vector) getDataArray returns null printer friendly version
next newest post | next oldest post
Author Messages
tilh
Private First Class

Gender: Male
Location: Singapore
Registered: Jul 2005
Status: Offline
Posts: 19

Click here to see the profile for tilh Send email to tilh Send private message to tilh Find more posts by tilh Edit or delete this message Reply w/Quote
Posted Saturday, November 12, 2005 @ 03:10:39  

When using insert(Vector) with Vector values filled in,
and subsequnt getDataArray() the array returns null, althought getValueAt()
returns correct values. Code and results below. Note that the line 1,x returns
nulls using the data array.

import java.awt.BorderLayout;
import java.io.*;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JFrame;
import quick.dbtable.*;

public class dBTableTest2 extends JFrame {
DBTable dBTable1;
/** Creates a new instance of dBTableTest */
public static final int COL_DEL = 0;
public static final int COL_RECID = 1;
public static final int COL_ACTIVITY = 2;
public static final int COL_START = 3;
public static final int COL_END = 4;
public static final int COL_NEXTDAY = 5;

public dBTableTest2() {
String[][] o = {
{"N","1","11","08:00","08:39","N"}
};

this.setLocationRelativeTo(null);
setSize(500,200);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
// InputStream in = new InputStream();
dBTable1 = new DBTable();
this.setVisible(true);
dBTable1.setVisible(true);
System.out.println (dBTable1.getVersion());
try {
dBTable1.refresh(o);
} catch (Exception e) {
e.printStackTrace();
}
String line1 = "N\t9\t99\t23:00\t23:39\tN";

String[] cols = line1.split("\t",-1);
Vector insertElements = new Vector(dBTable1.getColumnCount());
insertElements.setSize(dBTable1.getColumnCount() + 1);

insertElements.set(COL_RECID,cols[COL_RECID] + "," + "x");
insertElements.set(COL_DEL,"N");
insertElements.set(COL_ACTIVITY,cols[COL_ACTIVITY]);;
insertElements.set(COL_START,cols[COL_START]);
insertElements.set(COL_END,cols[COL_END]);
insertElements.set(COL_NEXTDAY,cols[COL_NEXTDAY]);
dBTable1.insert(insertElements);
dBTable1.save();
// for (int i = 0; i < insertElements.size(); i++) {
// System.out.println (insertElements.get(i));
// }

Object data[][] = dBTable1.getDataArray();
for (int i= 0; i < data.length; i++) {
Object line[] = data[i];
for (int j = 0 ; j < line.length; j++) {
System.out.println(i + "," + j + " -------- " + line[j]);
System.out.println(i + "," + j + " ........ " + dBTable1.getValueAt(i,j));
}
}
getContentPane().add(dBTable1, BorderLayout.CENTER);

}

public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
dBTableTest2 comp = new dBTableTest2();
comp.setVisible(true);
comp.toFront();
}
});
}
}
/////////////////////////////////
QuickTable 2.0.5.24
0,0 -------- N
0,0 ........ N
0,1 -------- 1
0,1 ........ 1
0,2 -------- 11
0,2 ........ 11
0,3 -------- 08:00
0,3 ........ 08:00
0,4 -------- 08:39
0,4 ........ 08:39
0,5 -------- N
0,5 ........ N
1,0 -------- null
1,0 ........ N
1,1 -------- null
1,1 ........ 9,x
1,2 -------- null
1,2 ........ 99
1,3 -------- null
1,3 ........ 23:00
1,4 -------- null
1,4 ........ 23:39
1,5 -------- null
1,5 ........ N

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Monday, November 14, 2005 @ 15:25:48  

We will look into this and get back to you.
Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Wednesday, November 16, 2005 @ 03:02:29  

If you replace the line as below, it works fine

//insertElements.setSize(dBTable1.getColumnCount() + 1);
insertElements.setSize(dBTable1.getColumnCount());

tilh
Private First Class

Gender: Male
Location: Singapore
Registered: Jul 2005
Status: Offline
Posts: 19

Click here to see the profile for tilh Send email to tilh Send private message to tilh Find more posts by tilh Edit or delete this message Reply w/Quote
Posted Wednesday, November 16, 2005 @ 21:28:15  

Sorry for the error... I had added a extra dynamic column somewhere else in the original code,
and hence add 1 more .... forgetting the the getColumnCount() gets the current size ...

My apologies.

Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios