miary
Posts: 8
|
| Posted: 02/15/2008, 11:53 AM |
|
When I perform an insert on a form, I get the following message placed in the {Error} label: unique constraint violation. This is a database (Oracle, ORA-00001) error, generated after the SQL statement has been executed.
I would like to customize that message but couldn't find a way to do so. In the documentation, under 'Examples & Techniques' -> Programming -> Processing Errors, there is an example about displaying custom error messages, but these examples don't deal with intercepting the value placed in the {Error} label.
Any clue?

P.S. Just in case, I use JSP. I tried the addError() function but no success.
|
 |
 |
datadoit
|
| Posted: 02/15/2008, 1:26 PM |
|
if (this that and the other) {
$Container->Errors->addError("Your error message here");
}
Is that what you're after? Typically this would go into a control or
the form's OnValidate event.
|
|
|
 |
miary
Posts: 8
|
| Posted: 02/15/2008, 3:02 PM |
|
I tried what you mentioned but it does not work, because of the sequence of events: the database error message is generated way after the validate (OnValidate).
I tried the codes below (this is the jsp equivalent), place in the event AfterExecuteInsert, but it errors out, saying that getControl is an invalid method 
String dbError = e.getControl().getErrorsAsString();
if (dbError.indexOf("unique constraint") > 0) {
e.getControl().clearErrors();
e.getControl().addError("This expert already has this expertise.");
}
I guess the question then is how do you overwrite the value assigned to the label {Error} and customizing it the way you want it, after an insert command has been performed.
|
 |
 |
wkempees
|
| Posted: 02/16/2008, 4:20 AM |
|
untried (yet)
use the translattion options.
"miary" <miary@forum.codecharge> schreef in bericht
news:247b5edb56ff82@news.codecharge.com...
> When I perform an insert on a form, I get the following message placed in
> the
> {Error} label: unique constraint violation.
>
> I would like to customize that message but couldn't find a way to do so.
> In the
> documentation, under 'Examples & Techniques' -> Programming -> Processing
> Errors, there is an example about displaying custom error messages, but
> these
> examples don't deal with intercepting the value placed in the {Error}
> label.
>
> Any clue?
>
> 
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
miary
Posts: 8
|
| Posted: 02/16/2008, 8:02 AM |
|
Tried the translation too. But that does not work because it is not where the error is coming. The application returns the error from the database (again: this is generated after an insert), not from the application.
Can this even be done?
|
 |
 |
DonB
|
| Posted: 02/16/2008, 4:11 PM |
|
You might find you need to change the Halt_On_Error property of your
connection (probably best if in the Before Execute .... events of the data
source. It may be halting the script before you can do anything with the
error. Look at db_mysql.php I think it's allowed values are yes, no,
report.
--
DonB
"miary" <miary@forum.codecharge> wrote in message
news:247b7090ae0b8d@news.codecharge.com...
> Tried the translation too. But that does not work because it is not where
> the
> error is coming. The application returns the error from the database
> (again:
> this is generated after an insert), not from the application.
>
> Can this even be done?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
miary
Posts: 8
|
| Posted: 02/20/2008, 9:58 PM |
|
The property below does not work. I don't want to halt the process, I just want to intercept and modify the returned error.
Any other ideas to make this happen? Somehow I thought this actually would be easy, but may be not
|
 |
 |
|