Re: Direct Actions and Sessions
Re: Direct Actions and Sessions
- Subject: Re: Direct Actions and Sessions
- From: Colin Clark <email@hidden>
- Date: Thu, 27 Nov 2003 18:14:11 -0500
Hi Chuck and Art,
Yes, you're both correct. Thanks for pointing out my typos.
Just to rectify my mistake, for the record:
1. Locking is essential. Those of us who have been working with WO know
the curses of not following the EOF commandments too well.
http://wodev.spearway.com/cgi-bin/WebObjects/WODev.woa/wa/
Main?wikiPage=EOFCommandments
2. Public instance variables suck.
(Except in WOComponents. Accessor methods for simple,
publicly-accessible, display variables are even grosser)
Generally speaking, I use controller code to handle access to my
editing contexts. It manages locking for me and helps guard against
lazy programming that can result in EOF disasters.
Thanks again,
Colin
On Thursday, November 27, 2003, at 04:38 PM, Chuck Hill wrote:
Yes, always lock. I'd take it even one step further:
Art Isbell wrote:
On 28/11/2003, at 1:59 AM, Colin Clark wrote:
public WOActionResults updateImageTitleAction() {
Integer imageNum =
Integer.parseInt(context().request().stringFormValueForKey("uniqueIma
ge Number"));
String newTitleForImage =
context().request().formValueForKey("title");
EOEditingContext ec = new EOEditingContext();
ec.lock();
try {
Image = (Image) EOUtilities.objectMatchingKeyAndValue(ec,
"Image", "imageNumber", imageNum);
image.setTitle = newTitleForImage;
Ick! Public instance variables are an abomination. I hope that was
typo...
image.setTitle(newTitleForImage);
Ah... that's better. :-)
ec.saveChanges();
} finally {
ec.unlock();
}
Better safe than deadlocked (unlikely in this case but possible if you
keep the ec around and an exception is raised from saveChanges().
Chuck
}
I've become paranoid about locking all editing contexts but the
session's default editing context. Please correct me if I'm wrong to
suggest the above in this situation.
Aloha,
Art
_______________________________________________
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.
--
Chuck Hill email@hidden
Global Village Consulting Inc.
http://www.global-village.net
Progress is the mother of all problems.
- G. K. Chesterton
_______________________________________________
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.
_______________________________________________
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.