Kbase 19529: Apptivity code example for opening message box before delete
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/02/2000 |
|
Apptivity version 3.2 code example for opening a message box before deleting a record
Add the delete record event to the datasource by clicking with the right mouse button within the Apptivity project on the datasource.
In the example the
project name is : Ondelete ,
the datasource name : dsCust
the name of resulting java source file generated by that action:
OndeletedsCustClientEvents.java . The only code added manually is
what shown below the line //TODO: Add your handler code here
public class OndeletedsCustClientEvents extends abDSEvents
{
public boolean deleteRecord () throws Exception
{
//TODO: Add your handler code here
Answer answer = new Answer(); // the User Module containing the answer
abMsgBox mymsgbox = new abMsgBox("delete record?","", answer);
mymsgbox.show();
// as long as there is no answer received
int i = 0;
while ((answer.answer == 'u')&&(i++ < 100)) {//take care to avoid deadlocks
try {Thread.sleep(100);} catch (Exception e) {e.printStackTrace();}
} // let the thread sleep , 10 sec time to answer
if (answer.answer == 'u') mymsgbox.close();//if no answer close the box
if (answer.answer == 'y') {
return(true);}
else {
theApp().showStatus("Deletion canceled");
return(false);
// ... continuation of automatically by Apptivity generated // code.
Additional only a User Module containing the answer below is needed:
// this class contains the received answer
import progress.apptivity.client.*;
class Answer implements abI_Observer {
protected char answer = 'u'; // like unknown yet
public boolean update(Object scr, Object arg) {
int received = ((abHint)arg).reason;
if ( received == abConst.OK) answer = 'y'; //like yes
if ( received == abConst.CANCEL) answer = 'n'; //like no
return true;
}
}
References To Written Documentation or Other
KnowledgeBase Documents:
Apptivity API Reference
KBase ID: 19466