validateAttribute custom error Message Not Showing Up
validateAttribute custom error Message Not Showing Up
- Subject: validateAttribute custom error Message Not Showing Up
- From: email@hidden
- Date: Thu, 08 Apr 2004 19:01:26 -0400
- Priority: normal
This is what I am trying to do. This is very similar to what is described here in
http://www.stepwise.com/Articles/Technical/WOValidation.html
I have an EO applicant (which is the type Subscriber EnterpriseObject) that is wired to the interface of the component NewSubscriber.java
In NewSubscriber.java :
public WOComponent saveUser(){
try{
applicant.validateForSave();
}
catch (EOValidation.Exception exception){
errorMessage = extract(exception.getMessage());
return null;
}
public void validationFailedWithException(java.lang.Throwable exception, Object value, String keyPath) {
if (keyPath.equals("applicant.firstName")){
errorMessage = extract(exception.getMessage());
validationDictionary.setObjectForKey(Boolean.TRUE, "firstNameValidationFailed");
}
}
In the EO Subscriber.java I have a custom message if first Name is not found :
public void validateFirstName(String firstName)throws EOValidation.Exception {
boolean firstNameCondition = ((firstName==null)|| (firstName.equals("")) );
if (firstNameCondition) {
String errorMessage = " You have not filled in all of the fields marked with a <font color=\"#CC0000\">RED ASTERISK*</font>. <br>";
errorMessage = errorMessage + "Please complete the fields and select submit.<br>";
throw new EOValidation.Exception(errorMessage);
}
}
When I hit submit and the button in NewSubscriber.java calls saveUser() I get the following generic message which I printed from within validationFailedWithException()
The 'firstName' property is not allowed to be NULL
I would like the custom message in validateFirstName() to show up which is in the EO.
Is this comprehensible? What am I doing wrong ?
When I do applicant.validateFirstName(applicant.firstName());
instead of applicant.validateForSave() the custom message is returned but I can't possibly do this for all fields, now can I ?
A. Shiraz
44 Executive Boulevard
Elmsford, NY 10523
(914) 592- 4203 x268
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.