Hi,
I need your help.
I use a grid, a form and a java-connector.
when I insert a new record, the new record’s color is displayed as red. (something is wrong!!)
In Oracle db, i find out that the new record is inserted correctly.
but in log file, the insert query is written twice.
so i add “debug code” in html. (beforeUpdate, afterupdate event call)
I found that the same insert query is called 2 times.
so i think that the first call is OK, but the 2nd call is not OK.
When updating, the result is the same.
I think that updating the same record again doesn’t occur an error. but it’s not normal.
Event process is like this:
- toolbar.onClick
- dp.OnBeforeUpdate: return false, so don’t call “insert query”
- Edit form’s field and click “submit button”
- Form.onButtonClick: contactForm.save()
- dp.OnBeforeUpdate: return true, so call “insert query” (state-inserted)
- Form.onButtonClick: alert(“after call…”). at this, I checked that a new record was inserted in DB .
- dp.OnBeforeUpdate: call again, why? I think that an error occurs here. (state-inserted)
- dp.onAfterUpdate: action-error
- dp.onAfterUpdate: action-error
log file is like this:
Client Code(html) is like this:
var contactsGrid = layout.cells(“a”).attachGrid();
contactsGrid.setHeader(“대분류,중분류,이름,비고”);
contactsGrid.setColumnIds(“DAEDIVI,JUNGDIVI,NAME,ETC”);
…
//form - right panel
contactForm = layout.cells(“b”).attachForm();
…
//saving data to server
var dpg = new dataProcessor(“/contact_manager/Etc_code_grid01_sel01”);
dpg.init(contactsGrid);
dpg.attachEvent(“onBeforeUpdate”, function(sid, state, data){
if ( state == “inserted” ){
alert(“dpg.BeforeUpdate.Inserted: sid-”+sid+“, state-”+state);
var daeDivi = contactsGrid.cells( sid, 0 ).getValue();
var jungDivi = contactsGrid.cells( sid, 1 ).getValue();
var nameD = contactsGrid.cells( sid, 2 ).getValue();
if( daeDivi == "" || jungDivi =="" || nameD ==""){
return false ;
}
}
else {
alert("dpg.BeforeUpdate.Else: sid-"+sid+", state-"+state);
}
return true ;
})
dpg.attachEvent("onAfterUpdate", function(sid, action, tid, tag){
if (action == "inserted"){
alert("dpg.AfterUpdate:Inserted: sid-"+sid+ ",tid-"+tid+", state-"+action);
contactsGrid.selectRowById(tid);
contactForm.setFocusOnFirstActive();
}
else {
alert("dpg.onAfterUpdate.Else: sid-"+sid+",tid-"+tid+", state-"+action);
}
})
contactForm.attachEvent("onButtonClick", function(id){
contactForm.save();
alert("after call...");
});
Java code(server) is like this:
((DBDataWrapper)c.sql).sequence(“SEQ_ETC_CODE.nextVal”);
((DBDataWrapper)c.sql).attach( OperationType.Insert ,“INSERT INTO SB_ETC_CODE_TEST (CODE,DAEDIVI,JUNGDIVI,DESCI,ETC) values (‘{DAEDIVI}{JUNGDIVI}’, ‘{DAEDIVI}’, ‘{JUNGDIVI}’, ‘{DESCI}’, ‘{ETC}’)”);
c.render_table(“SB_ETC_CODE_TEST”, “CODE”, “DAEDIVI,JUNGDIVI,DESCI,ETC”);
Thank you for any help.