--Considering Check Constraints from the Database
1 post
• Page 1 of 1
--Considering Check Constraints from the Database
This article is outdated - please use our new system at
https://doc.sibvisions.com
In addition to the use of Default Values the restriction to "allowed values" is another advantage of JVx.
The "allowed values"for columns are usually defined in the database using check constraints. These are evaluated by JVx and assumed as so called allowed values.
The constraints directly impact the user interface, as the user is only offered the allowed values in the form of Choice Cell Editors.
Example
Based on the example for Default Values, we define the following check constraints (Oracle Syntax):
- Code: Select all
alter table USERS
add constraint USER_ACTIVE_CHECK
check (active IN ('Y', 'N'));
alter table USERS
add constraint USER_CHANGE_PASSWORD_CHECK
check (CHANGE_PASSWORD IN ('Y', 'N'));
Therefore the fields "ACTIVE" and "CHANGE_PASSWORD" can only contain "Y" or "N".
So that in the user interface the correct Choice Cell Editor is used, this must be defined. This is done globally by calling:
- Code: Select all
UIChoiceCellEditor.addDefaultChoiceCellEditor(editor);
A Choice Cell Editor from the ApplicationUtil has already defined for the values "Y" and "N".
The following methods can be used to disable the check constraints detection:
- Code: Select all
//per instance
users.setAllowedValues(false);
//for all instances (static)
DBStorage.setDefaultAllowedValues(false);
If no check constrains are used in the database, the allowed values can be set via the API:
- Code: Select all
users.open();
//sets allowed/possible values
users.getMetaData().getColumnMetaData("ACTIVE").setAllowedValues(new Object[] {"Y", "N"});
-
Development@SIB - Posts: 325
- Joined: Mon Sep 28, 2009 1:54 pm
1 post
• Page 1 of 1