Problems with Preferences
Problems with Preferences
- Subject: Problems with Preferences
- From: Greg Hulands <email@hidden>
- Date: Wed, 30 Jun 2004 09:09:45 +1000
Hi,
I am converting my preferences from been written to a file, to be
stored in the database. Because most of the prefs are textually based,
the attribute that stores the pref value is a varchar. Because I need
to store some EOKeyGlobalID's I am trying to serialize the gid and then
write the bytes to a string to store in the database.
public void setGiftCertificateProduct(Product p) {
EOEditingContext ec = p.editingContext();
EOKeyGlobalID key;
ec.lock();
key = (EOKeyGlobalID)ec.globalIDForObject(p);
ec.unlock();
Preferences pf =
localCopyOfPreference(app.preferenceForKey("GiftCertificateProduct"));
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(key);
byte[] bytes = bos.toByteArray();
String v = new String(bytes);
pf.setValue(v);
didChange(pf);
} catch (Exception e) {
System.out.println("Error Writing Prefs");
}
}
The problem I am experiencing is that when I create the string I am
getting a "{null}" in the debugger. For some reason it isn't writing it
to the byte array. I tried by changing to a FileOutputStream which I
wrote to a file and it worked fine. I cannot for the life of me figure
out why it would write it to the file, but not the byte array.
Does anyone know why this would happen or if they have experienced this
before?
Any help is greatly appreciated.
Regards,
Greg
_______________________________________________
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.