After few weeks of developing.... ( slow development ) :(
Im now facing a problem that i've never encountered before...
And that problem is in my DataSetHandler. ...
I've initialized ROOMS, CURRENTGUESTS and RESERVEDGUESTS (DataSetHandler objects) as members of the main class.
@ RESERVEDGUESTS
I've made a button(EDIT) to be able to update the data that was stored on RESERVEDGUESTS. ...
[CODE=JAVA] if(!jList2.isSe lectionEmpty()) {
Object ob = RESERVEDKEYS.ge t(jList2.getSel ectedIndex());
ArrayList<Objec t> al = new ArrayList<Objec t>();
al.add(RESERVED GUESTS.getNthEl ement(ob,0));
al.add(RESERVED GUESTS.getNthEl ement(ob,15));
al.add(RESERVED GUESTS.getNthEl ement(ob,16));
DataSetHandler dsh = RESERVEDGUESTS; //<<<<<<SUSPECT ED
dsh.removeDataS et(ob);
new RegisterFilter( this,true,CURRE NTGUESTS,dsh,al ).setVisible(tr ue);
if(new File("schedule. temp").exists() ){
}
}[/CODE]
The code above is where i get stucked....
On that implementation,
I was just initializing dsh from DataSetHandler object RESERVEDGUESTS.
my purpose is to remove the specific key and its member and pass to the Dialog that manipulates the rescheduling, guest's prefered rooms etc....
RESERVEDGUESTS should not be touched... so i've created another one....
If the editing is successful(upda ted), then no problem because the RSVN(Reservatio n) number was removed and replaced by a new one or the updated one....
But if the editing was canceled, so the current values will just be refreshed...
But, after refreshing the lists,
I now can't find the key and its member.... ( nullpointerexce ption occured )...
I get stucked for a half an hour, tracing that F* bug.
and now it was proven 100% that the responsible for removing that key(supposed to be removed to use as a reference on editing) is the
Base on my observation, the dsh and the RESERVEDGUESTS are one,
I can't imagine, because on my other implementation, there was no problem...
(That is exactly the same on this, the only difference is more keys was also removed)
Base on the snippet above(that 2 lines), What's wrong?
whatever i will do to dsh, RESERVEDGUESTS should not be changed right?
But, the RESERVEDGUESTS is affected, whatever i did to dsh, it reflects to RESERVEDGUESTS. ... Please correct me( i might forgot something here)
As i've remove the key ob in dsh, the RESERVEDGUESTS also affected,
I expect that ob is still in RESERVEDGUESTS after the snippet above(2 lines)...
I tried to use clone method, that returns an object, but i get an error that says,
clone method is protected in Object class at java.lang....
If this can be the other alternative, can you show me a sample code that implements a copying of object through clone? or just a URL?
I tried this,
The compiler says that CloneNotSupport edException must be handled(or put a try/catch block)
Now, if that exception occurs, How can i reimplement my DataSetHandler to be able to support cloning of that object?
Im now facing a problem that i've never encountered before...
And that problem is in my DataSetHandler. ...
I've initialized ROOMS, CURRENTGUESTS and RESERVEDGUESTS (DataSetHandler objects) as members of the main class.
@ RESERVEDGUESTS
I've made a button(EDIT) to be able to update the data that was stored on RESERVEDGUESTS. ...
[CODE=JAVA] if(!jList2.isSe lectionEmpty()) {
Object ob = RESERVEDKEYS.ge t(jList2.getSel ectedIndex());
ArrayList<Objec t> al = new ArrayList<Objec t>();
al.add(RESERVED GUESTS.getNthEl ement(ob,0));
al.add(RESERVED GUESTS.getNthEl ement(ob,15));
al.add(RESERVED GUESTS.getNthEl ement(ob,16));
DataSetHandler dsh = RESERVEDGUESTS; //<<<<<<SUSPECT ED
dsh.removeDataS et(ob);
new RegisterFilter( this,true,CURRE NTGUESTS,dsh,al ).setVisible(tr ue);
if(new File("schedule. temp").exists() ){
}
}[/CODE]
The code above is where i get stucked....
On that implementation,
I was just initializing dsh from DataSetHandler object RESERVEDGUESTS.
my purpose is to remove the specific key and its member and pass to the Dialog that manipulates the rescheduling, guest's prefered rooms etc....
RESERVEDGUESTS should not be touched... so i've created another one....
If the editing is successful(upda ted), then no problem because the RSVN(Reservatio n) number was removed and replaced by a new one or the updated one....
But if the editing was canceled, so the current values will just be refreshed...
But, after refreshing the lists,
I now can't find the key and its member.... ( nullpointerexce ption occured )...
I get stucked for a half an hour, tracing that F* bug.
and now it was proven 100% that the responsible for removing that key(supposed to be removed to use as a reference on editing) is the
Code:
DataSetHandler dsh = RESERVEDGUESTS; //<<<<<<SUSPECTED dsh.removeDataSet(ob);
I can't imagine, because on my other implementation, there was no problem...
(That is exactly the same on this, the only difference is more keys was also removed)
Base on the snippet above(that 2 lines), What's wrong?
whatever i will do to dsh, RESERVEDGUESTS should not be changed right?
But, the RESERVEDGUESTS is affected, whatever i did to dsh, it reflects to RESERVEDGUESTS. ... Please correct me( i might forgot something here)
As i've remove the key ob in dsh, the RESERVEDGUESTS also affected,
I expect that ob is still in RESERVEDGUESTS after the snippet above(2 lines)...
I tried to use clone method, that returns an object, but i get an error that says,
clone method is protected in Object class at java.lang....
If this can be the other alternative, can you show me a sample code that implements a copying of object through clone? or just a URL?
I tried this,
Code:
DataSetHandler dsh = (DataSetHandler)RESERVEDGUESTS.clone();
Now, if that exception occurs, How can i reimplement my DataSetHandler to be able to support cloning of that object?
Comment