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 > CellEditor/Renderer Post New Topic   Post A Reply
javadatepicker tableCellEditor printer friendly version
next newest post | next oldest post
Author Messages
infow
Unregistered
Edit or delete this message Reply w/Quote
Posted Thursday, April 13, 2006 @ 10:31:04  

i'm using your quicktable and the component date from javadatepicker (www.javadatepicker.com , you can download a demo version on this site)
and the problem is when i make a cellEditor for this date field into your table !
Everything is ok (selecting a date) but not when the date selected is null. The table is putting the old date again back when i leavec the cell editor ! ! ! and before leaving the cell, i have - - and when i leave, i have the old date back ! ! !

I have try since 2 days and it's not working. JavadatePicker says that the problem must be in your component.
Here is a sample ... Could you told me what to do ?

thank in advance

public class myMain extends JFrame
{
public myMain ()
{
//OrderModel myCellModel = new OrderModel();
MyCellListener cellListner = new MyCellListener();
CellPropertiesModelDefault cellProp = new CellPropertiesModelDefault();
//set Frame properties
setSize(300,200);
setVisible(true);

//create a new quicktable
quick.dbtable.DBTable dBTable1 = new quick.dbtable.DBTable();

//add to frame
getContentPane().add(dBTable1);

//set the database driver to be used, we are using jdbc-odbc driver
dBTable1.setDatabaseDriver("sun.jdbc.odbc.JdbcOdbcDriver");

/*
set the jdbc url,"quicktabledemo" is the data source we have created
for the database
*/
dBTable1.setJdbcUrl("jdbc:odbc:quicktabledemo");

// set the select statement which should be used by the table
dBTable1.setSelectSql("select * from employee");

//to create the navigation bars for the table
dBTable1.createControlPanel();
dBTable1.addTableCellListener(cellListner);
dBTable1. setCellPropertiesModel(cellProp);


try
{
//connect to database & create a connection
dBTable1.connectDatabase();

//fetch the data from database to fill the table
dBTable1.refresh();

dBTable1.createColumnModelFromQuery();
Column colonne = dBTable1.getColumn(3);
colonne.setUserCellEditor(new CellEditorDate());

}
catch(SQLException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}

}
class MyCellListener implements DBTableCellListener
{
public Object cellValueChanged(int row, int col, Object oldValue, Object newValue)
{
return newValue;
}

}

public class CellPropertiesModelDefault extends CellPropertiesModel implements Serializable
{
public int getCellEditable(int row, int col)
{
return 1;
}

}
public static void main(String[] args)
{
//create a new table frame
myMain myframe = new myMain ();
}
}

public class CellEditorDate implements CellComponent
{
JDatePicker j = new JDatePicker();

public void addActionListener(ActionListener arg0)
{
// TODO Auto-generated method stub

}

public JComponent getComponent()
{
// TODO Auto-generated method stub
return j;
}

public Object getValue()
{
// TODO Auto-generated method stub
return j.getSelectedDate();
}

public void setValue(Object arg0)
{
if (arg0==null)
j.setSelectedDate(null);
else

j.setSelectedDate((java.util.Date)arg0);

}
}

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 Thursday, April 13, 2006 @ 14:36:03  

Could you modify the following method as below in your CellEditorDate class. Run your program and check what is the returned date, when the date selected is null?

Code:

public Object getValue()
{
// TODO Auto-generated method stub
Date result = j.getSelectedDate();
System.out.println("Returned date=" + result);
return result;
}
infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Tuesday, April 18, 2006 @ 09:41:42  

i have this line:
Returned date=null

thank for your help

--------------------
Olivier

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 Tuesday, April 18, 2006 @ 23:13:04  

can you turn on debug by setting dbTable.debug=true and check the debug messages?
infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Wednesday, April 19, 2006 @ 07:27:32  

i have nothing debug for this action :

Returned date=null

when i put a date, it's ok and i have this trace:
Returned date=Sat Apr 22 00:00:00 CEST 2006
Data updated (0,3): oldvalue: null new value: Sat Apr 22 00:00:00 CEST 2006

I HAVE FOUND A SOLUTION. can you tell me if it's seems good ? (i must change the null to "") :

public Object getValue()
{
// TODO Auto-generated method stub
Date result = j.getSelectedDate();

System.out.println("Returned date=" + result);
if (result==null)
return "";
else
return result;
//return j.getSelectedDate();
}

public void setValue(Object arg0)
{
if (arg0==null || arg0.toString().compareTo("")==0)
j.setSelectedDate(null);
else

j.setSelectedDate((java.util.Date)arg0);

}

thank in advance and have a nice day

--------------------
Olivier

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 Thursday, April 20, 2006 @ 11:22:08  

Your solution is fine. we will look into why it doesn't work for null.
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