Re: takeValuesFromForm Validation
Re: takeValuesFromForm Validation
- Subject: Re: takeValuesFromForm Validation
- From: Peter Vandoros <email@hidden>
- Date: Wed, 01 Aug 2007 17:09:44 +1000
Hi Owen,
In your validationFailedWithException() method, add this:
public void validationFailedWithException(java.lang.Throwable exception,
java.lang.Object value, java.lang.String keyPath) {
// add to array of error messages
....
// try to force the value
try {
// value = the Object parameter to this method (2nd parameter)
// keyPath = the String parameter to this method (3rd parameter)
takeValueForKeyPath( value, keyPath );
}
catch (IllegalArgumentException e) {
// just ignore it... we've already added the exception to the array
of validationErrors
}
}
Regards
Peter
Owen McKerrow wrote:
Hi All,
I have an attribute in an entity that has a width of 1500 char. I have
over ridden the validate method for it inside the entities java
class.....
public String validateRqfJustification(String newState) throws
NSValidation.ValidationException
{
if ( newState != null ) {
if (newState.length() > 1500) {
throw new NSValidation.ValidationException("The RQF
Justification can not be longer than 1500 characters");
}
}
return newState;
}
This gets called fine when I try to save it.
However if I submit the form and the text field contains more than
1500 chars, a validation error is thrown, without going into this
method because it checks it against the width inside the model.
I catch this exception inside the component
validationFailedWithException() method, the page gets return I display
the error message ( not the nicely formatted one form above, but the
default one ). BUT the value of the form in the feild has been reset
to what it was before they click the button. This is not what I want.
I want to tell them they can't save but the value in the field should
stay the same as what they just typed.
So 2 questions :
1) When a form is submitted why doesn't it use my validation method
for that attribute ? What validation is it calling ? i.e.
validateforUpdate() ?
2) How can I get the value the user typed to stay in the form,
instead of being truncated back ?
Owen McKerrow
WebMaster, emlab
Ph : +61 02 4221 5517
http://emlab.uow.edu.au
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
'The test of a first-rate intelligence is the ability to hold two
opposed ideas in the mind at the same time and still be able to
function.'
-F.Scott Fitzgerald,
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
Peter Vandoros
Software Engineer
Etech Group Pty Ltd
Level 3/21 Victoria St
Melbourne VIC 3000
Australia
Ph: +61 3 9639 9677
Fax: +61 3 9639 9577
----------------------------------
IMPORTANT: This e-mail message and any attachments are confidential and
may be privileged. If received in error, please reply to this message
and destroy all copies and any attachments. You should check this
message and any attachments for viruses or defects. Our liability is
limited to resupplying any affected message or attachments. For more
information about Etech Group, please visit us at
http://www.etechgroup.com.au.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden