Subject | Re: [IBO] Display custom "xxx is a required field" message |
---|---|
Author | joseph osende |
Post date | 2002-03-11T15:36:36Z |
Hi, Mirco !
I'm new to IBO, but anyway I'd like to show
the solution that I'm actually using
1. create a constraint for your not nullable field
alter table <tableName> add constraint
<constraintName>
check ( fieldName is Not Null ) ;
please make your <constraintName> short, unique,
and "auto descriptive", for example,
NN_tablename_fieldname
2. somewhere in your Delphi App, I do it in an on
'OnPostError' event, you can compare the name
of your constraint with the content of E.message,
something like :
if ( pos( constraintName, e.message ) <> 0 ) then
// the error is your nullable field related
// so you can display a customized message
// to the end-user
// 'cause your constraintName is unique
// the context is completely known
begin
// display a message and suggestions
// set the appropriate value
// for the action to be taken
// abort, fail, etc.
end ;
3. toward a global solution...
In fact I've created a table containing
the constraints names, the customized messages,
and the suggestions, initialize an Array at my app's
startup and whenever I get an IB_Error and I try
to find in my array the row containing the
constraintName found in the TIB_Error.message
If the search succeeds, I can display the
corresponding message and suggestions.
Hope it can help
Joseph
Do You Yahoo!? -- Une adresse @... gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
I'm new to IBO, but anyway I'd like to show
the solution that I'm actually using
1. create a constraint for your not nullable field
alter table <tableName> add constraint
<constraintName>
check ( fieldName is Not Null ) ;
please make your <constraintName> short, unique,
and "auto descriptive", for example,
NN_tablename_fieldname
2. somewhere in your Delphi App, I do it in an on
'OnPostError' event, you can compare the name
of your constraint with the content of E.message,
something like :
if ( pos( constraintName, e.message ) <> 0 ) then
// the error is your nullable field related
// so you can display a customized message
// to the end-user
// 'cause your constraintName is unique
// the context is completely known
begin
// display a message and suggestions
// set the appropriate value
// for the action to be taken
// abort, fail, etc.
end ;
3. toward a global solution...
In fact I've created a table containing
the constraints names, the customized messages,
and the suggestions, initialize an Array at my app's
startup and whenever I get an IB_Error and I try
to find in my array the row containing the
constraintName found in the TIB_Error.message
If the search succeeds, I can display the
corresponding message and suggestions.
Hope it can help
Joseph
> Anyone knows how to display a custom message instead___________________________________________________________________________
> of IBO's built-
> in "xxx is a required field" message? I tried the
> database's onError
> event, but it gets only called when the database
> reports an error
> which in this case does not happen (IBO seems to
> check the required
> fields before posting - good, but how do I change
> the msg then?)
>
> Mirco
>
>
> ------------------------ Yahoo! Groups Sponsor
>
>
> IB Objects - direct, complete, custom connectivity___________________________________________________________________________
> to Firebird or InterBase
> without the need for BDE, ODBC or any
> other layer.
>
> http://www.ibobjects.com - your IBO community___________________________________________________________
> resource for Tech Info papers,
> keyword-searchable FAQ, community code contributions
> and more !
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
Do You Yahoo!? -- Une adresse @... gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com