update dataprovider

L.S.

I used the 'performing inserts, updates and deletes' tutorial to implement this functionality in my web app. Instead of the the table I used a form to perform the inserts and updates. The inserts work fine, however, I cannot get my update code to work properly.

In the table I've got an update button. When the user clicks the button a form opens in a Layout Panel with the old data displayed in input components. The user can then edit the data and click an updateOK button. In that button's action event handler I've got the following code:

form1.discardSubmittedValues(搃nsertOK?;

try {

openinghoursDataProvider.setCursorRow(rk);

provideData();

openinghoursDataProvider.commitChanges();

} catch (Exception ex) {

log("Error Description", ex);

exceptionST.setText(揇uplicate openinghour?;

return null;

}

reset();

return null;

}

The following is the code of my insert feature, which works fine:

public String insertOKButton_action() {

form1.discardSubmittedValues(搖pdateOK?;

try {

rk = openinghoursDataProvider.appendRow();

openinghoursDataProvider.setCursorRow(rk);

provideData();

openinghoursDataProvider.commitChanges();

} catch (Exception ex) {

log("Error Description", ex);

exceptionST.setText(揇uplicate openinghour?;

return null;

}

reset();

return null;

}

So, I think it's the openinghours.setCursorRow(rk) bit that's causing the trouble.

Thanks for helping me out.

Kind regards,

Annet.

[1622 byte] By [JagXa] at [2007-11-27 6:54:31]
# 1
It is not clear how do you get the rk value in the first case? It seems like it is the key of the trouble.
zulua at 2007-7-12 18:29:33 > top of Java-index,Development Tools,Java Tools...
# 2

Thanks for your reply Zulu,

rk is a property of type RowKey.

It gets its value in the following method which is the event handler of the update button in the table component, which opens a layout panel with a form.

public String updateButton_action() {

discard();

try {

rk = tableRowGroup1.getRowKey();

if (rk != null) {

dayDD.setSelected(openinghoursDataProvider.getValue(搊peninghours.dayId, rk));

fromTF.setText(openinghoursDataProvider.getValue(搊peninghours.fromTime? rk));

toTF.setText(openinghoursDataProvider.getValue(搊peninghours.toTime? rk));

peakoffpeakRBG.setSelected(openinghoursDataProvider.getValue(

搊peninghours.p_opId, rk).toString());

}

} catch (Exception ex) {

log("ErrorDescription", ex);

error(ex.getMessage());

}

set();

insertOKButton.setVisble(false);

updateOKButton.setVisble(true);

return null;

}

I hope you can help me solve the problem, taking this additional information into account. I apologise for not mentioning this.

Kind regards,

Annet.

JagXa at 2007-7-12 18:29:33 > top of Java-index,Development Tools,Java Tools...