Am 09.02.2005 um 21:42 schrieb Chuck Hill:
You might find the sections in Practical WebObjects on this topic of
use.
If you are using direct actions _without_ a session, there is only
the appendToResponse phase. If the page generated contains component
actions then a session is created and so you would handle locking
normally. If the page contains only direct actions, the pattern is:
- create the EC,
- lock the EC
- create and configure the return page
- call generateResponse on the return page
- unlock the ec
- dispose the ec
- return the previously generated response _NOT_ the page!
You might as well override appendToResponse in your page:
public void appendToResponse(..) {
ec = new EOEditingContext();
ec.lock();
try {
// pull values from request, configure, whatever
super.appendToResponse(..);
} finally {
ec.unlock();
}
}
and return the page. Looks a lot easier to me, and all the code is in
one place...
Cheers, Anjo