On Mar 27, 2008, at 3:30 PM, Mike Schrag wrote: YourPage backgroundPage = ERXApplication.instantiatePage( YourPage.class.getName() );
You MAY want to go the context clone route, or you will lose the original context's headers, which might break links if you need virtual hosting info or whether or not the current request is HTTPS or not.
... actually, even a clone didn't help -- it had to be a new context, note new WOContext(null) below. Since I'm eventually dropping a string into a page with its own original context and not actually making a response any browser will see, I assume a 'null' context works fine since it doesn't get used anyway. ____________________________________
On Mar 27, 2008, at 2:20 PM, Mike Schrag wrote: We're looking at various options -- improve the Java code, generate the reports off-line as static HTML, etc.
I would recommend probably computing the report in a long response, pushing the results into an intermediate model (not necessarily EO-based, maybe just POJO's) and then render that in your page. I've never tried actually RENDERING a page in a long response, but I suspect it's going to be sort of nasty to get it behaving properly. You should not be using your long response's context if you are -- you should make a new one (or clone your current context). This should be roughly equivalent to the docs for ERJavaMail where it talks about sending component-based emails. ms
Many thanks, Mike. Your pointer to the notes in the ERJavaMail application was the perfect one -- the answer was there, I needed to provide a new context. Now the code is, in part (all the rest is the same as before):
@Override public Object performAction() { logger.info("--> performAction");
WOContext calcCntx = new WOContext(null); Calc calcPage = (Calc) WOApplication.application(). pageWithName(Calc.class.getName(), calcCntx); return calcPage.generateResponse().contentString(); }
Other things to note, now I have my sample working.
You CAN render in a long response (at least with the simple HTML below).
The WebObjects parser is really fast! In order to get a page that took about 5 seconds to render, I used:
<wo:WORepetition count = "200"> <wo:WORepetition count = "2000"> <wo:string value="[x]"/> </wo:WORepetition></wo:WORepetition>
and generated 1000 random numbers each time I satisfied the "[x]" binding! That makes me wonder just how awful the code must be in the real application .. as best I know it really can consume over 30 seconds mostly rendering its report. |