Having great difficulty getting the data out of my JTable once it is populated and then the data is changed by the user. I extended DefaultTableModel for my tableModel then returned a ResultSet via SQLJ to populate the table. The data displays when I run the
Applet and I have overridden isCellEditable making cells 1 to 8 editable. Structure of the table is as follows:
ID, Project, hrsMon hrsSun,total hrs
int,
String, float, float, float, float, float, float, float, float
When I call getDataVector and try to display the data (for debug, what I really need to do is post changes to the db: oracle by the way) I get back null.
Code Snippet for accessing getDataVector:
private void saveData()
{
Vector newVector;
String newString[];// = new String[10];
String stupidString;
try
{
newVector = aModel.getDataVector();
newVector.trimToSize();
newString = new String[newVector.size()];
//just
testing to see if I can show one element from the Vector. What
//I'll really do is pass the Vector to a SQLJ
servlet then parse the data
//out and insert into the db.
stupidString = newString[1];
//newString[1] = (String)newVector.elementAt(2);
//newString = newVector.toString();
}
catch(Exception e)
{
e.printStackTrace();
System.out.println(e.getMessage());
newString = new String[10];
stupidString ="err";
}
JOptionPane.showMessageDialog(null,"Record = "+stupidString);
//return newString;
}
As you can see I tried a couple different ways of getting the data out of the Vector but have met with defeat.
Tried the tutorial using tables and this part seems to be assumed that we'd know how to do it.
Any help will be greatly appreciated.
Thanks
Stuart