Nicolas Bielza wrote:
Thanks, but I can't think of any more testing to do..
I wanted to use sendPage() since there really is no need for continuation in my flow..
If I use sendPageAndWait() and log something in the catch(return), I can see that the lasy initialization is executed after that (and if I close the session in the catch(return), I can see that the lazy initialization fails).
Maybe "someone"'s code did not use lazy collections ?
He assures me he does.
Here's a cut down sample of some of his working code:The fix I'm using now is to fetch lazy collections elements in my query.
function scenario () {
var factory = cocoon.getComponent (PersistanceFactory.ROLE);
var session = factory.createSession ();
try {
var scenario = MyObj.load (session, new java.lang.Long (something), null);
cocoon.sendPage (cocoon.parameters["screen"], { scenario: scenario });
catch (return) { session.close(); } // the page has finished rendering
} catch (e) {
cocoon.log.error (e);
cocoon.sendPage("screen/error", {message: "scenarios.scenario.notavailable"});
session.close();
} finally {
cocoon.releaseComponent(factory);
}
}
How does yours match? Could you post it?
Regards, Upayavira
-----Original Message-----
From: Upayavira [mailto:[EMAIL PROTECTED] Sent: 10 juin, 2004 14:50
To: [EMAIL PROTECTED]
Subject: Re: Flow + Hibernate and lazy initialization
Nicolas Bielza wrote:
Thanks, I tried this and the catch(return) is not interpreted when using sendPage(), it's just ignored.
I also tried your previous suggestion, but my app was not responding anymore, maybe the "FOM_Cocoon.suicide();" line is required ?
Anyway, this probably won't help much, since I also tried the postpipeline code with sendPageAndWait() and it's also interpreted before the view is rendered. This looks like a bug : The http://cocoon.apache.org/2.1/userdocs/flow/api.html#sendPageAndWait
page says :
"If provided, the postPipelineCode function will be executed after pipeline processing is complete but before the script is suspended. You
can use this to release resources that are needed during the pipeline processing but should not become part of the continuation"I'd say persevere with the catch(return) idea. The reason I proposed it is because I asked someone who had exactly that problem with Hibernate, and it works for him. And he was advised by the person who coded a lot of the flow stuff.
If the "catch(return)" code is interpreted just before the script is suspended, then it looks like the script is suspended BEFORE the pipeline processing is complete ! So the postpipeline code is really a postpipelineinvocation code.
It looks like the only solution that would work is to use a filter servlet but I don't have such things in my environment :(
Regards, Upayavira
Regards,
Nicolas.
-----Original Message----- From: Upayavira [mailto:[EMAIL PROTECTED] Sent: 10 juin, 2004 14:14 To: [EMAIL PROTECTED] Subject: Re: Flow + Hibernate and lazy initialization
Nicolas Bielza wrote:
Well, when I say that they "work", I mean that they are interpreted and
not ignored. I'm not sure that they actually "work", since they don't seem to wait for the view to be rendered. (but maybe this is by design..)
Try this:
function someFunction() {
var session = ... ...
cocoon.sendPage(...);
catch (return) {
// after calling the view layer but before control // leaves the interpreter
}
}
Note, the catch is not associated with a try.
This came of the previously referenced http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations but that page is pretty frightening.
Hope this helps.
Regards, Upayavira
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
