Re: [gnome-db] libgnomedb: data validation



On 11/30/06, Murray Cumming <murrayc murrayc com> wrote:
Does, for instance, the GnomeDbGrid do any checks on the input before
trying to set it in the database? For instance, does it stop the user
from entering text in a numeric field, or stop you from entering numbers
outside of the possible range?

For numerical values, the individual cell renderers used in a grid, or
the data entry widgets used in a form will let you enter any
character, but the returned value is the same as if you used the
atoi() family functions.

The current implementation does not let you do any specific formatting
nor any specific control. However there is only some code to add to
make this possible, there is no infrastructure to change, in fact this
is already done for the existing plugins within libgnomedb. More
specifically, have a look at the gnome_db_util_new_cell_renderer() and
related functions in the gnome-db-tools.c file (for example for the
GnomeDbEntryPict plugin, which definition files are in
data-entries/plugins/).


How does the UI behave if the database server rejects the data?


The problem is more generic than that, because a grid may display data
which is not related to something in a database. In fact the grid
widget just displays what's in its proxy (created on top of the
GdaDataModel which contains data to display). So the answer is that
the behaviour of the grid (or form for that matter) is the same as the
GdaDataProxy object.

Specifically to the situation you mention, the GdaDataModel to display
must be a GdaDataModelQuery object. Here is what happens when the user
wants to apply the changes made:
1- the GdaDataProxy sends the GDA_DATA_MODEL_HINT_START_BATCH_UPDATE
hint to tell that it will make several modifications at once
2- the GdaDataProxy tries to apply the changes for each row which has
been modified, and stops as soon as a change is refused by the
GdaDataModelQuery
3- upon asked to do a change, the GdaDataModelQuery tries to run the
pre-defined modification query and returns the success status of that
query. It also flags itself for a future re-run of its SELECT query to
refresh its contents
4- he GdaDataProxy sends the GDA_DATA_MODEL_HINT_END_BATCH_UPDATE
hint, and the GdaDataModelQuery re-runs its SELECT query (which makes
it change its contents which are propagated up to the grid itself)

So the displayed data is always a re-run of the SELECT query of the
GdaDataModelQuery object.

Sorry for my long answer but I prefer to give more details...

Cheers,

Vivien



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]