FileUpload
FileUpload
- Subject: FileUpload
- From: "Jonathan Fleming" <email@hidden>
- Date: Tue, 28 Jan 2003 16:43:29 +0000
I am having a problem with the "if" statement on this piece of code shown
below, I have set it to upload something if a filepath is available and to
do nothing or more to the point leave it in the same state if the filepath
is null, however, when I set the "if" statement to != null on save I still
find that an empty or null entry has been made to the database, effectivly
overwriting the data that was already there, which is what I did not want to
do.
When I do the reverse for the "if" statement == null, I get nothing saved to
the database whether or not a filepath has been entered.
I tried to solve the problem but it is eluding me. Can anyone help please.
Regards
Jonathan
Here's the code:
//instance variables
protected String kvcPicLrgRef = null;
protected String kvcPicThumbRef = null;
// Thumb File Upload Of File Path
public void setKvcPicThumbRef(String aFilePath) {
kvcPicThumbRef = NSPathUtilities.lastPathComponent(aFilePath);
}
public String getKvcPicThumbRef() {
return kvcPicThumbRef;
}
// Thumb File Upload of Data
public void setKvcPicThumb(NSData aPicture) {
kvcPicThumb = aPicture;
}
public NSData getKvcPicThumb() {
return kvcPicThumb;
}
/*---------------------- Validation ---------------------*/
public WOComponent dbSaveChanges(){
try {
tbJobPicture.validateForSave();
// get editing context
EOEditingContext ec = session().defaultEditingContext();
TbJobPicture tbJobPicture = tbJobPicture();
// this checks if data was entered into the fileUpload component
if (getKvcPicThumbRef() != null)
{
// Something was uploaded, update the EO
tbJobPicture.setPicThumbRef(getKvcPicThumbRef());
tbJobPicture.setPicThumbnail(getKvcPicThumb());
}
// save changes made in editing context to object store
ec.saveChanges();
// create a new tbJob
tbJobPicture = new TbJobPicture();
}
catch (NSValidation.ValidationException exception) {
validationDictionary.setObjectForKey(Boolean.TRUE,
"saveValidationFailed");
validationDictionary.setObjectForKey(exception.getMessage(),
"saveValidationString");
}
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
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.