Kbase 17857: Apptivity: more on assigning values without user interaction
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
Apptivity: more on assigning values without user interaction
There are a number of different ways to provide a column
value when inserting new records without having the user
enter the value.
Trap the server side datasource event of "addnew" and in the
PRE pass, add a abColValue object to the list of column values
sent from the client side.
public int addNew (int pass, abQueryImpl arg, Object arg2)
throws Exception
{
// in the case of the addNew event, you could just add your
// column value to the list of column values that will be
// inserted.
if (pass == abConst.PRE)
{
// add the value to the list
abVector list = (abVector) arg2;
abColValue colval =
new abColValue("orderID", new abInteger(234));
// note, the use of abInteger.
// The abColValue requires an abStreamable object
list.addElement(colval);
}
return(-1);
}
Trap the client side datasource event of "update" and check
the datasource for isAddMode().
public boolean updateRecord () throws Exception
{
// here is another place you could use to initialize a
// value in a column at this point the datasource update()
// method has been called and the new record is about to
// be sent to the server.
if (currentDS().isAddMode())
{
try {
abColumn id = theApp().getColumn("orders", "orderID");
id.setValue(new Integer(234));
} catch(Exception e)
{
// if column value cannot be set, don't do update
Alert.runAlertExternally("Insert Error",
"Could not set key value","OK", null, null);
return(false);
}
}
return(true);
}
Other related kbases include:
17611 Programatically assigning key fields (getInsertValue)
17834 Apptivity: assigning default values to a data source
PES 04/17/98
Progress Software Technical Support Note # 17857