rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Data Access Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

IliDataSource Class Reference

Gadget class. More...

#include <ilviews/dataccess/gadgets/datasrc.h>

Inheritance diagram for IliDataSource:
IliDataGem IlvGadget IlvSimpleGraphic IlvGraphic IliMemoryDataSource IliSQLDataSource

List of all members.

Public Member Functions

 IliDataSource (IlvDisplay *display, const IlvPoint &at, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 The constructor initializes a data source.
void addErrorMessage (const char *msg)
 Forwards an application error message described by msg to all the error sinks that have been added with the addErrorSink member function.
void addErrorMessage (const IliErrorMessage &msg)
 Forwards the error message msg to all the error sinks that have been added with the addErrorSink member function.
void addErrorSink (IliErrorSink *sink)
 Adds error sink.
IlBoolean applyQueryMode (IlBoolean interactive=IlFalse)
 Applies the query that the user specified while in query mode.
void applyToFields (IliDataSourceFieldCallback cb, IlAny arg)
 Calls the callback function for each field managed by the data source.
void cancel ()
 Cancels any user input awaiting validation.
void cancelQueryMode ()
 Cancels query mode by restoring the original data source table.
void clear ()
 Calls the IliTable::clearRows member function on the table of the data source.
IlBoolean deleteCurrentRow ()
 Deletes the current row of the data source (as long as the current row is an actual row).
void dontDeleteRow ()
 Call this member function from the onPrepareDeleteRow virtual member function, or from the corresponding callback to cancel the row deletion.
void dontValidateRow ()
 Call this member function from one of the onValidateRow , onPrepareInsert, or onPrepareUpdate virtual member functions, or from one of their corresponding callbacks.
void enableAutoRowLocking (IlBoolean f)
 Specifies whether auto-row-locking mode is enabled for the data source.
void enableAutoSelect (IlBoolean autoSelect)
 Specifies whether auto-select mode is enabled for the data source.
void enableInsert (IlBoolean)
 Specifies whether insertion is allowed.
virtual IlvBitmapgetBitmap () const
 Returns the bitmap that is displayed during the design phase in Rogue Wave Views Data Access.
IlInt getColumnsCount () const
 Returns the number of columns in the table.
IlInt getCurrentRow () const
 Returns the position of the current row.
IlInt getDeletedRow () const
 Returns the position of the row that is currently being deleted if called from the onDeleteRow member function, or returns the position of the row that is to be deleted if called from the onPrepareDeleteRow member function (or from the corresponding callback).
IliTablePropertyManagergetEffectiveTablePropertyManager ()
 Returns the effective table property manager used by the data source.
const IliTablePropertyManagergetEffectiveTablePropertyManager () const
 Returns the effective table property manager used by the data source.
IliErrorReportergetErrorReporter () const
 Returns the error reporter that is used by the reportErrors member functions.
IlInt getFetchedRow () const
 Returns the position of the row that is currently being fetched.
IlInt getRowsCount () const
 Returns the number of rows in the table.
IliTablegetTable ()
 Returns the table of the data source.
const IliTablegetTable () const
 Returns the table of the data source.
const char * getTablePropertyManagerName () const
 Returns the name of the table property manager used by the data source or NULL if the default table property manager is used. Initially, this property is NULL.
const IliValuegetValue (IliName colname) const
 Returns the current value of one column.
const IliValuegetValue (IlInt colno) const
 Returns the current value of one column.
IlBoolean gotoFirst ()
 Changes the current row of the data source to the first row of the table after validating any pending user input.
IlBoolean gotoLast ()
 Changes the current row of the data source to the insert row, provided insertion is allowed, or to the last row if not.
IlBoolean gotoNext ()
 Changes the current row of the data source to the next row after validating any pending user input.
IlBoolean gotoPrevious ()
 Changes the current row of the data source to the previous row (as long as the current row is not the first row).
IlBoolean gotoRow (IlInt rowno)
 Changes the current row of the data source to a row.
IlBoolean isAutoRowLockingEnabled () const
 Returns IlTrue if the data source automatically calls refreshAndLockRow on the underlying table as soon as an attempt to modify an existing row is made.
IlBoolean isAutoSelectEnabled () const
 Returns IlTrue if auto-select mode is enabled for the data source.
IlBoolean isCurrentRowNull () const
 Returns IlTrue if all the columns of the current row have a null value.
IlBoolean isEditable () const
 Returns IlTrue if the data source is not read-only, and if it is currently positioned on a valid row or on the insert row.
IlBoolean isInputModified () const
 Returns IlTrue if the user has edited any of the fields managed by the data source.
IlBoolean isInQueryMode () const
 Returns IlTrue if the data source is currently in query mode.
IlBoolean isInsertEnabled () const
 Returns IlTrue if new rows can be inserted in the table through the data source.
IlBoolean isOnInsertRow () const
 Returns IlTrue if the current row is the insert row.
IlBoolean isQueryModeSupported () const
 Returns IlTrue if the query mode is supported.
IlBoolean isReadOnly () const
 Returns IlTrue if the data source is read-only.
IlBoolean isUsingTableProperties () const
 Returns IlTrue if the data source uses table properties.
virtual void onCancelEdits ()
 Called just after the current edits have been canceled.
virtual void onDeleteRow ()
 Called each time a row is about to be deleted from the data source table.
virtual void onEnterInsertMode ()
 Called when the data source enters insert mode.
virtual void onEnterModifiedState ()
 Called just after the data-source changes its state from "not-modified" to "modified".
virtual void onEnterRow ()
 Called whenever the data source enters a new row.
virtual void onEnterUpdateMode ()
 Called when the data source enters update mode.
virtual void onFetchRow ()
 Called when the data source table is a two-tier table, and each time a new row is fetched from the remote database and stored in the table cache.
virtual void onPrepareDeleteRow ()
 Called when the user attempts to delete a row through this data-source or when the deleteCurrentRow member function is called.
virtual void onPrepareInsert ()
 Called just before a row is inserted into the data source table.
virtual void onPrepareUpdate ()
 Called just before a row is updated in the data source table.
virtual void onQuitInsertMode ()
 Called just after a row has been inserted in the data source table.
virtual void onQuitRow ()
 Called just before leaving a row.
virtual void onQuitUpdateMode ()
 Called just after a row has been updated in the data source table.
virtual void onValidateRow ()
 Called by the validate member function before actually updating the data source table (for both update and insert rows).
IlBoolean refreshAndLockCurrentRow (IlBoolean keepCurrentChanges=IlFalse)
 Refreshes and lock current row.
IlBoolean refreshCurrentRow (IlBoolean keepCurrentChanges=IlFalse)
 Refreshes current row.
void removeErrorSink (IliErrorSink *sink)
 Removes an error sink from this data source.
void reportErrors (const IliErrorList &errorList) const
 Reports the errors that are contained in an error list.
IlBoolean select ()
 Calls the IliTable::select member function on the table of the data source and then moves to the first row of the table.
void setErrorReporter (IliErrorReporter *reporter)
 Sets the error reporter.
virtual void setGlobalScope (IlBoolean)
 Specifies whether the scope of the name of the data gem is local to the container in which it is located or globally visible.
void setReadOnly (IlBoolean only)
 Specifies whether the data source is read-only.
virtual void setTable (IliTable *table, IlBoolean owner=IlTrue)
 Sets the table of the data source.
void setTablePropertyManagerName (const char *name)
 Sets the table property manager name.
IlBoolean setValue (IliName colname, const IliValue &value)
 Sets the data source value of one column.
IlBoolean setValue (IlInt colno, const IliValue &value)
 Sets the data source value of one column.
void setValueModified (IliName colname, IlBoolean flag)
 Changes the modified attribute of the value of one column.
void setValueModified (IlInt colno, IlBoolean flag)
 Sets the modified attribute of a value of one column.
IlBoolean startInsert ()
 Changes the current row of the data source to the insert row, provided insertion is allowed.
IlBoolean switchToQueryMode ()
 Switches to query mode.
void useTableProperties (IlBoolean flag)
 Enables/Disables use table properties.
IlBoolean validate (IlBoolean interactive=IlFalse)
 Validates the current row.

Static Public Member Functions

static IlvSymbol * CancelEditsSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * DeleteRowSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * EnterInsertModeSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * EnterModifiedStateSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * EnterRowSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * EnterUpdateModeSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * FetchRowSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * PrepareDeleteRowSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * PrepareInsertSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * PrepareUpdateSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * QuitInsertModeSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * QuitRowSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * QuitUpdateModeSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.
static IlvSymbol * ValidateRowSymbol ()
 Returns the callback name which is called by the corresponding virtual member function.

Friends

class IliFieldItf

Detailed Description

Gadget class.

Library: dbgadget

The IliDataSource class defines a gadget that holds an IliTable and that can manage a set of field gadgets located in one or more containers. Each of these field gadgets is connected to a column of the table. In addition, the data source acts like a cursor in the table, because at any point in time it is positioned on a particular row of the table. Member functions are provided that enable the data source to move to the next row, previous row, and so on. A data source is characterized by the following properties:

Each time the current row index of a data source is changed to a new value, the data source row buffer is updated with a copy of the designated table row. If the new current row does not designate a valid row in the table, the data source row buffer is updated with null values. The data source input-modified property is also cleared.

At this time, any fields that are connected to the data source are updated with a value from the row buffer. This value corresponds to the column which the field gadget is connected to. The user can then edit the values displayed in the fields or, alternatively, can call the setValue member function. The data source input-modified property is set to IlTrue at this time. In addition, the data source calls either the onEnterInsertMode or onEnterUpdateMode virtual member functions, depending on whether the current row index points to the insert row or not. Any new values edited by the user in the field gadgets are copied to their corresponding position in the row buffer.

Later, the user can call the validate member function. This will trigger some system-defined and some user-defined checks on the row buffer (see the onValidateRow, onPrepareInsert, and onPrepareUpdate virtual member functions). If the checks succeed, either a new row is inserted into the table or the table row is updated from the data source row buffer (depending on whether the current row is the insert row or not). The input-modified property of the data source is set to IlFalse.

As an alternative to the validate method function, the user can call cancel. In this case, the contents of the row buffer are dismissed, the row buffer is updated from the existing table row (or with null values if the current row does not designate a row in the table), and any field gadgets are updated with values from row buffer. The input-modified property is set to IlFalse.

See also:
IliErrorMessage, IliErrorReporter, IliErrorSink, IliRepository, IliValue, IliDataSourceFieldCallback.

Constructor & Destructor Documentation

IliDataSource::IliDataSource ( IlvDisplay display,
const IlvPoint at,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

The constructor initializes a data source.

Parameters:
display The display.
at The location.
thickness The border thickness.
palette The palette.

Member Function Documentation

void IliDataSource::addErrorMessage ( const char *  msg  ) 

Forwards an application error message described by msg to all the error sinks that have been added with the addErrorSink member function.

This member function may be called by one of the onValidateRow, onPrepareInsert, or onPrepareUpdate virtual member functions, or by the corresponding callbacks.

Parameters:
msg The message.
void IliDataSource::addErrorMessage ( const IliErrorMessage msg  ) 

Forwards the error message msg to all the error sinks that have been added with the addErrorSink member function.

This member function may be called by one of the onValidateRow, onPrepareInsert or onPrepareUpdate virtual member functions, or by the corresponding callbacks.

Parameters:
msg The message.
void IliDataSource::addErrorSink ( IliErrorSink sink  ) 

Adds error sink.

All errors that occur on the data source table, and all errors that are thrown by one of the addErrorMessage member functions, will be forwarded to this error sink. Note that the data source will not delete the error sink at destruction time, so the same error sink may be safely shared among many data sources.

Parameters:
sink The error sink.
IlBoolean IliDataSource::applyQueryMode ( IlBoolean  interactive = IlFalse  ) 

Applies the query that the user specified while in query mode.

The original data source table is restored and its select member function is called. If the interactive parameter is IlTrue, any errors that occur will be reported to the user by calling the reportErrors member function.

Parameters:
interactive The interactive flag.
Returns:
IlTrue if successful.
void IliDataSource::applyToFields ( IliDataSourceFieldCallback  cb,
IlAny  arg 
)

Calls the callback function for each field managed by the data source.

Repeatedly calls the callback function for each field managed by the data source using in the following:

 callback(dataSource, field, colno, arg);

The callback takes as its parameters the data source itself, the field, the position of the column to which the field is connected, and the arg parameter. Some fields, such as table gadgets, are not connected to a particular column. In this case, the colno parameter will be -1.

Parameters:
cb The callback.
arg The user data.
void IliDataSource::cancel (  ) 

Cancels any user input awaiting validation.

The input-modified property of the data source is cleared. This member function calls the onCancelEdits virtual member function.

static IlvSymbol* IliDataSource::CancelEditsSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
void IliDataSource::clear (  ) 

Calls the IliTable::clearRows member function on the table of the data source.

If the table is a one-tier table, this deletes all rows. If the table is a two-tier table, the local row cache of the table is cleared. Any pending user input is canceled by this member function.

IlBoolean IliDataSource::deleteCurrentRow (  ) 

Deletes the current row of the data source (as long as the current row is an actual row).

Returns:
IlTrue if successful.
static IlvSymbol* IliDataSource::DeleteRowSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
void IliDataSource::enableAutoRowLocking ( IlBoolean  f  ) 

Specifies whether auto-row-locking mode is enabled for the data source.

Parameters:
f The auto-row-locking permission.
void IliDataSource::enableAutoSelect ( IlBoolean  autoSelect  ) 

Specifies whether auto-select mode is enabled for the data source.

Parameters:
autoSelect The auto-select mode flag.
void IliDataSource::enableInsert ( IlBoolean   ) 

Specifies whether insertion is allowed.

Parameters:
enable The insertion flag.
static IlvSymbol* IliDataSource::EnterInsertModeSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::EnterModifiedStateSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::EnterRowSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::EnterUpdateModeSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::FetchRowSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
virtual IlvBitmap* IliDataSource::getBitmap (  )  const [virtual]

Returns the bitmap that is displayed during the design phase in Rogue Wave Views Data Access.

Returns:
The bitmap.

Reimplemented from IliDataGem.

Reimplemented in IliMemoryDataSource, and IliSQLDataSource.

IlInt IliDataSource::getColumnsCount (  )  const

Returns the number of columns in the table.

Returns:
The number of columns.
IlInt IliDataSource::getCurrentRow (  )  const

Returns the position of the current row.

Returns:
-1 if the data source is not positioned on a row or a value equal to getRowsCount() if the data source is positioned on the insert row.
IlInt IliDataSource::getDeletedRow (  )  const

Returns the position of the row that is currently being deleted if called from the onDeleteRow member function, or returns the position of the row that is to be deleted if called from the onPrepareDeleteRow member function (or from the corresponding callback).

Returns:
The row position.
IliTablePropertyManager* IliDataSource::getEffectiveTablePropertyManager (  ) 

Returns the effective table property manager used by the data source.

Returns:
The table property manager.
const IliTablePropertyManager* IliDataSource::getEffectiveTablePropertyManager (  )  const

Returns the effective table property manager used by the data source.

It is obtained as follows:

  • If the useTableProperties property is IlFalse, this member function returns NULL.
  • Otherwise, if the tablePropertyManagerName property is not NULL, the table property manager with that name is returned.
  • Otherwise, the default table property manager is returned.
Returns:
The table property manager.
IliErrorReporter* IliDataSource::getErrorReporter (  )  const

Returns the error reporter that is used by the reportErrors member functions.

When this property is NULL a default error reporter is used. Initially this property is NULL.

Returns:
The error reporter.
IlInt IliDataSource::getFetchedRow (  )  const

Returns the position of the row that is currently being fetched.

This member function may be called from the onFetchRow member function or from the corresponding callback.

Returns:
The row position.
IlInt IliDataSource::getRowsCount (  )  const

Returns the number of rows in the table.

Returns:
The number of rows.
IliTable* IliDataSource::getTable (  ) 

Returns the table of the data source.

Returns:
The table.
const IliTable* IliDataSource::getTable (  )  const

Returns the table of the data source.

Returns:
The table.
const char* IliDataSource::getTablePropertyManagerName (  )  const

Returns the name of the table property manager used by the data source or NULL if the default table property manager is used. Initially, this property is NULL.

Returns:
The name of the table property manager.
const IliValue& IliDataSource::getValue ( IliName  colname  )  const

Returns the current value of one column.

Note that this is the data source value for the column, as opposed to the underlying table value.

Parameters:
colname The column name.
Returns:
The value.
const IliValue& IliDataSource::getValue ( IlInt  colno  )  const

Returns the current value of one column.

Note that this is the data source value for the column, as opposed to the underlying table value.

Parameters:
colno The column position.
Returns:
The value.
IlBoolean IliDataSource::gotoFirst (  ) 

Changes the current row of the data source to the first row of the table after validating any pending user input.

Returns:
IlTrue if successful.
IlBoolean IliDataSource::gotoLast (  ) 

Changes the current row of the data source to the insert row, provided insertion is allowed, or to the last row if not.

Any pending user input is first validated by this member function.

Returns:
IlTrue if successful.
IlBoolean IliDataSource::gotoNext (  ) 

Changes the current row of the data source to the next row after validating any pending user input.

If the current row is the last row of the table and if insertion is allowed, the current row changes to the insert row.

Returns:
IlTrue if successful.
IlBoolean IliDataSource::gotoPrevious (  ) 

Changes the current row of the data source to the previous row (as long as the current row is not the first row).

Any pending user input is first validated by this member function.

Returns:
IlTrue if successful.
IlBoolean IliDataSource::gotoRow ( IlInt  rowno  ) 

Changes the current row of the data source to a row.

Any pending user input is first validated by this member function.

Parameters:
rowno The row position. If rowno equals -1 , the data source will not be positioned on any row. If rowno equals getRowsCount(), the current row will change to the insert row.
Returns:
IlTrue if successful.
IlBoolean IliDataSource::isAutoRowLockingEnabled (  )  const

Returns IlTrue if the data source automatically calls refreshAndLockRow on the underlying table as soon as an attempt to modify an existing row is made.

This is useful when using IliSQLTable objects in order to implement the "pessimistic concurrency control policy". For more information, see the description of the IliSQLTable::getConcurrencyControl member function. Initially, this property is set to IlFalse.

Returns:
The auto row lock permission.
IlBoolean IliDataSource::isAutoSelectEnabled (  )  const

Returns IlTrue if auto-select mode is enabled for the data source.

When auto-select mode is enabled, the data source automatically calls the select member function if an event occurs. The table of a data source may have parameters already defined. Some of these parameters may have been mapped onto other data sources. Therefore, we can say that a data source depends on another data source through its table parameters. Then, provided auto-select mode is enabled, the data source will call the select member function whenever one of the data sources on which it depends undergoes a current row change. Initially, this property is set to IlFalse.

Returns:
The auto-select mode flag.
IlBoolean IliDataSource::isCurrentRowNull (  )  const

Returns IlTrue if all the columns of the current row have a null value.

Returns:
IlTrue if the current row is null.
IlBoolean IliDataSource::isEditable (  )  const

Returns IlTrue if the data source is not read-only, and if it is currently positioned on a valid row or on the insert row.

Returns:
The editable flag.
IlBoolean IliDataSource::isInputModified (  )  const

Returns IlTrue if the user has edited any of the fields managed by the data source.

Returns:
IlTrue if an editing has been done.
IlBoolean IliDataSource::isInQueryMode (  )  const

Returns IlTrue if the data source is currently in query mode.

Returns:
The query mode state.
IlBoolean IliDataSource::isInsertEnabled (  )  const

Returns IlTrue if new rows can be inserted in the table through the data source.

Initially, this property is set to IlTrue.

Returns:
The insert permission.
IlBoolean IliDataSource::isOnInsertRow (  )  const

Returns IlTrue if the current row is the insert row.

Returns:
IlTrue if the data source is positioned on the insert row.
IlBoolean IliDataSource::isQueryModeSupported (  )  const

Returns IlTrue if the query mode is supported.

Returns:
The query mode support flag.
IlBoolean IliDataSource::isReadOnly (  )  const

Returns IlTrue if the data source is read-only.

If the data source is read-only, the end-user cannot modify the table via the fields managed by the data source. Initially, this property is set to IlFalse.

Returns:
The read-only flag.
IlBoolean IliDataSource::isUsingTableProperties (  )  const

Returns IlTrue if the data source uses table properties.

Initially, this property is IlTrue.

Returns:
The table properties using flag.
virtual void IliDataSource::onCancelEdits (  )  [virtual]

Called just after the current edits have been canceled.

The default implementation of this virtual member function calls the CancelEdits callback.

virtual void IliDataSource::onDeleteRow (  )  [virtual]

Called each time a row is about to be deleted from the data source table.

The index of the row can be obtained by the getDeleteRow member function. The default implementation of this virtual member function is to call the DeleteRow callback. The dontDeleteRow member function can be used to cancel the row deletion.

virtual void IliDataSource::onEnterInsertMode (  )  [virtual]

Called when the data source enters insert mode.

The default implementation of this virtual member function calls the EnterInsertMode callback.

virtual void IliDataSource::onEnterModifiedState (  )  [virtual]

Called just after the data-source changes its state from "not-modified" to "modified".

This typically happens when the end user starts modifying a field connected to the data-source or when the setValue member function is called. This virtual member function can be overridden to do the following :

  • Check that it is possible to enter the modified state at this time and, if not, then call the cancel member function.

Note that it is not possible to use the onEnterUpdateMode or onEnterInsertMode virtual member functions for this purpose since they are called before the state of the data-source changes (and hence calling cancel would not have any effect in this case). The default implementation of this virtual member function calls the EnterModifiedState callback.

virtual void IliDataSource::onEnterRow (  )  [virtual]

Called whenever the data source enters a new row.

The default implementation of this virtual member function calls the EnterRow callback.

virtual void IliDataSource::onEnterUpdateMode (  )  [virtual]

Called when the data source enters update mode.

The default implementation of this virtual member function calls the EnterUpdateMode callback.

virtual void IliDataSource::onFetchRow (  )  [virtual]

Called when the data source table is a two-tier table, and each time a new row is fetched from the remote database and stored in the table cache.

The index of the row that has been fetched can be obtained by the getFetchedRow member function. The default implementation of this virtual member function calls the FetchRow callback.

virtual void IliDataSource::onPrepareDeleteRow (  )  [virtual]

Called when the user attempts to delete a row through this data-source or when the deleteCurrentRow member function is called.

The index of the row which is to be deleted can be obtained by calling the getDeletedRow member function. This virtual member function can be overridden to do the following :

  • Check any application defined constraints. If the constraints are not satisfied, the dontDeleteRow should be called. In this case, deleteCurrentRow will not delete the row. Instead, it will return a value of IlFalse.
  • In addition, the addErrorMessage member function can be called to describe the reason of the failure.

The default implementation of this virtual member function calls the PrepareDeleteRow callback.

virtual void IliDataSource::onPrepareInsert (  )  [virtual]

Called just before a row is inserted into the data source table.

This virtual member function may check that the row is correct, and it may also alter the row prior to inserting the table. In addition, it may decide that the row is invalid, and reject the table insert by calling the dontValidateRow member function. In this case, it may call the addErrorMessage member function to provide the user with an error message. The default implementation of this virtual member function calls the PrepareInsert callback.

virtual void IliDataSource::onPrepareUpdate (  )  [virtual]

Called just before a row is updated in the data source table.

This virtual member function may check that the row is correct and it may also alter the row prior to updating the table. In addition, it may decide that the row is invalid and reject the table update, by calling the dontValidateRow member function. In this case, it may call the addErrorMessage member function to provide the user with an error message. The default implementation of this virtual member function calls the PrepareUpdate callback.

virtual void IliDataSource::onQuitInsertMode (  )  [virtual]

Called just after a row has been inserted in the data source table.

The default implementation of this virtual member function calls the QuitInsertMode callback.

virtual void IliDataSource::onQuitRow (  )  [virtual]

Called just before leaving a row.

The default implementation of this virtual member function calls the QuitRow callback.

virtual void IliDataSource::onQuitUpdateMode (  )  [virtual]

Called just after a row has been updated in the data source table.

The default implementation of this virtual member function calls the QuitUpdateMode callback.

virtual void IliDataSource::onValidateRow (  )  [virtual]

Called by the validate member function before actually updating the data source table (for both update and insert rows).

This virtual member function can be overridden to do the following:

  • Check any application defined constraints. If the constraints are not satisfied, the dontValidateRow member function should be called. In this case validate will not update the table. Instead it will return a value of IlFalse and the data source will remain in the input-modified state.
  • In addition, the addErrorMessage member function may be called to describe the reason for the failure.
  • Modify the data source values before the actual update of the table takes place.

The default implementation of this virtual member function calls the ValidateRow callback. For example, if you subclass the IliDataSource class, you can override the onValidateRow virtual member function with the following:

 class MyDataSource: public IliDataSource {
     ...
     virtual void onValidateRow() {
         if (getValue("Qty") > 15) {
             addErrorMessage("Invalid quantity");
             dontValidateRow();
         }
     }
 }

or, alternatively, if you do not subclass the IliDataSource class, you may use a callback:

 void ILVCALLBACK MyValidateRowCallback(IlvGraphic* g, IlAny) {
     IliDataSource* ds = (IliDataSource*)g;
     if (ds->getValue("Qty").asInteger() > 15) {
         ds->dontValidateRow();
         ds->addErrorMessage("Invalid quantity");
     }
 ...
 IliDataSource* ds = ...;
 ds->setCallback(IliDataSource::ValidateRowSymbol(),
                 MyValidateRowCallback);
static IlvSymbol* IliDataSource::PrepareDeleteRowSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::PrepareInsertSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::PrepareUpdateSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::QuitInsertModeSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::QuitRowSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
static IlvSymbol* IliDataSource::QuitUpdateModeSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
IlBoolean IliDataSource::refreshAndLockCurrentRow ( IlBoolean  keepCurrentChanges = IlFalse  ) 

Refreshes and lock current row.

This member function does the same thing as the refreshCurrentRow member function. In addition, if the remote database supports it, the remote row that corresponds to the current row is locked so that other users cannot modify or delete it as long as the lock is held. See the description of the IliTable::refreshAndLockRow member function and the IliSQLTable class for more information on row locking.

Parameters:
keepCurrentChanges The "keepCurrentChanges" flag.
Returns:
true if successful.
IlBoolean IliDataSource::refreshCurrentRow ( IlBoolean  keepCurrentChanges = IlFalse  ) 

Refreshes current row.

If the underlying table is a two-tier table, this member function re-reads the current row values from the remote database. If the optional keepCurrentChanges parameter is IlTrue, any columns of the data source that contain changes awaiting validation will keep these changes pending. Only unchanged columns will be updated. If keepCurrentChanges is IlFalse, all columns are updated without regard to the "modified" state. With a one-tier table, this member function does nothing.

Parameters:
keepCurrentChanges The "keepCurrentChanges" flag.
Returns:
IlTrue if successful.
void IliDataSource::removeErrorSink ( IliErrorSink sink  ) 

Removes an error sink from this data source.

Parameters:
sink The error sink.
void IliDataSource::reportErrors ( const IliErrorList errorList  )  const

Reports the errors that are contained in an error list.

This member function makes use of the error reporter returned by getErrorReporter if any, otherwise it uses a default error reporter.

Example

Here is an example that shows how errors can be trapped:

 IliDataSource* ds = ...;
 IliErrorList errors;
 ds->addErrorSink(&errors);
 ds->setValue("NAME", "Smith");
 if (!ds->validate()) {
    IlvPrint("First error: %s", errors.getErrorAt(0).getMessage());
    ...
 }
 ds->removeErrorSink(&errors);
Parameters:
errorList The error list.
IlBoolean IliDataSource::select (  ) 

Calls the IliTable::select member function on the table of the data source and then moves to the first row of the table.

Any pending user input is canceled by this member function.

Returns:
IlTrue if successful.
void IliDataSource::setErrorReporter ( IliErrorReporter reporter  ) 

Sets the error reporter.

Note that the data source will not delete the error reporter at destruction time, so the same error reporter may be safely shared among many data sources.

Parameters:
reporter The error reporter.
virtual void IliDataSource::setGlobalScope ( IlBoolean  global  )  [virtual]

Specifies whether the scope of the name of the data gem is local to the container in which it is located or globally visible.

Parameters:
global The data source scope (IlTrue for global).

Reimplemented from IliDataGem.

void IliDataSource::setReadOnly ( IlBoolean  only  ) 

Specifies whether the data source is read-only.

Parameters:
only The read only flag.
virtual void IliDataSource::setTable ( IliTable table,
IlBoolean  owner = IlTrue 
) [virtual]

Sets the table of the data source.

Parameters:
table The table.
owner To specify whether the data source becomes the owner of the table if IlTrue.
void IliDataSource::setTablePropertyManagerName ( const char *  name  ) 

Sets the table property manager name.

Parameters:
name The table property manager name. If NULL or an empty string, the default table property manager will be used.
IlBoolean IliDataSource::setValue ( IliName  colname,
const IliValue value 
)

Sets the data source value of one column.

Consequently, all fields connected to the column are updated with the new value without the underlying table being affected. A side effect of calling this member function is that the data source input is modified.

Parameters:
colname The column name.
value The value.
Returns:
IlTrue if successful.
IlBoolean IliDataSource::setValue ( IlInt  colno,
const IliValue value 
)

Sets the data source value of one column.

Consequently, all fields connected to the column are updated with the new value without the underlying table being affected. A side effect of calling this member function is that the data source input is modified.

Parameters:
colno The column position.
value The value.
Returns:
IlTrue if successful.
void IliDataSource::setValueModified ( IliName  colname,
IlBoolean  flag 
)

Changes the modified attribute of the value of one column.

Parameters:
colname The column name.
flag The modified flag.
void IliDataSource::setValueModified ( IlInt  colno,
IlBoolean  flag 
)

Sets the modified attribute of a value of one column.

Normally, the value of a column is considered unmodified when it is set by the data source (such as when an EnterRow or CancelEdits event occurs). Then it may become modified if the user edits this value or if it is changed by the setValue member function. With the setValueModified member function, it is possible to fool the data source and let it believe that that a column value has not been modified.

Parameters:
colno The column position.
flag The modified flag.
IlBoolean IliDataSource::startInsert (  ) 

Changes the current row of the data source to the insert row, provided insertion is allowed.

Any pending user input is first validated by this member function.

Returns:
IlTrue if successful.
IlBoolean IliDataSource::switchToQueryMode (  ) 

Switches to query mode.

If query mode is supported, this member function changes the data source table to a special memory table dedicated to contain query conditions.

Returns:
IlTrue if successful.
void IliDataSource::useTableProperties ( IlBoolean  flag  ) 

Enables/Disables use table properties.

Parameters:
flag If IlTrue, the data source will use table properties.
IlBoolean IliDataSource::validate ( IlBoolean  interactive = IlFalse  ) 

Validates the current row.

Validation is carried out in the following way:

  • If the row buffer of the data source is unmodified, validation succeeds immediately.
  • Otherwise, system-defined constraints are checked on the current row buffer. If these constraints are not satisfied, validation fails.
  • The onValidateRow virtual method is then called. It checks any application-defined constraints and if these are not satisfied, it calls the dontValidateRow member function. In this case, validation fails.
  • Either the onPrepareInsert or onPrepareUpdate virtual member function is called (depending on whether the current row is the insert row or not).
  • A new row is then inserted into the underlying table or an existing row is updated in the underlying table (depending on whether the current row is the insert row or not). If successful, either the onQuitInsertMode or onQuitUpdateMode virtual member function is called and IlTrue is returned.

If successful, the row buffer of the data source becomes unmodified. If the interactive parameter is IlTrue, any errors that may occur are automatically reported to the user by calling the reportErrors member function. If the interactive parameter is IlFalse, errors are not reported.

Parameters:
interactive The interactive flag.
Returns:
IlTrue if successful.
static IlvSymbol* IliDataSource::ValidateRowSymbol (  )  [static]

Returns the callback name which is called by the corresponding virtual member function.

Returns:
The callback name.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.