• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Altering Your Validation Code For a String iVar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Altering Your Validation Code For a String iVar


  • Subject: Altering Your Validation Code For a String iVar
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Tue, 25 Feb 2003 13:20:58 +0000

Hi mmalcolm,

I use your validation code (www.stepwise.com)to validate objects that are being saved to the database through an EOCustomObject, but when I want to validate a String Object that is to be saved to the database through setting theEOCustomObject's set/get methods on that String I can not get the validation to work.
What would I need to alter on this code for example:
I don't know if I am changing the code in the right place here.




   public void validationFailedWithException(java.lang.Throwable exception,
                                             java.lang.Object value,
                                             java.lang.String keyPath) {
       String tbClientPath = "tbClient.";

if (keyPath.startsWith(tbClientPath)) {
String field = keyPath.substring(tbClientPath.length(), keyPath.length());


validationDictionary.setObjectForKey(Boolean.TRUE,
field + "ValidationFailed");
validationDictionary.setObjectForKey(exception.getMessage(),
field + "ValidationString");
}


/*-------- I'VE ADDED THIS CODE BUT NOT SURE IF THIS SHOULD BE HERE ---------*/
if (sCountOfImagesToUpload != null)
{
for (int index=0; index<sCountOfImagesToUpload.length(); index++)
{
char c = sCountOfImagesToUpload.charAt(index);
if ( !Character.isDigit(c) )
{
String field = "countOfUploadRemainder";


validationDictionary.setObjectForKey(Boolean.TRUE,
field + "ValidationFailed");
validationDictionary.setObjectForKey(exception.getMessage(),
field + "ValidationString");
}
}
}
/*--------------------------------------------------------------------------*/
}


I want to make sure that the String has a digit in it and not a character, I then use this code in the saveChanges() method to get the data into the database/EOCustomObject:
Ive checked this using an attribute/property in the EOModel and it validates fine but i donwant to use that since I use the instance (sCountOfImagesToUpload) variable to calculate against what is already in the property i am about to update or save to.


// this checks if a number was entered into the sCountOfImagesToUpload variable
if ( iCountOfImagesToUpload > 0 )
{
total = iCountOfImagesToUpload + nCountOfUploadRemainder.intValue();
Integer sum = new Integer(total);
// this statement enters the value in database through EOCustomObject
tbClient.setCountOfUploadRemainder( sum );
setSCountOfImagesToUpload("0");
} else {
setSCountOfImagesToUpload("0");
}


Thanks for any help
Jonathan

_________________________________________________________________
Stay in touch with MSN Messenger http://messenger.msn.co.uk
_______________________________________________
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.

  • Prev by Date: Update in D2WS
  • Next by Date: Associate ON DELETE CASCADE with a foreign key
  • Previous by thread: Update in D2WS
  • Next by thread: Associate ON DELETE CASCADE with a foreign key
  • Index(es):
    • Date
    • Thread