Antranig - August 5, 2008

Rendering Sosusa Pages Using RSF

mjnsakai: still up?
AntranigBasman: Yes
mjnsakai: I have a question concerning R
mjnsakai: SF
mjnsakai: (go figure)
mjnsakai: How would I go about collecting the rendered result of a producer before it is sent back in the HTTP request?
mjnsakai: I'd like to render and save Sousa pages.
AntranigBasman: I see
mjnsakai: It's just a thought at this stage.
AntranigBasman: You would want to both send them over HTTP and to another place?
AntranigBasman: Or just to another place
mjnsakai: No, I see this as a "compile" operation.
mjnsakai: so just saved to a file.
mjnsakai: or more like a resource.
mjnsakai: Could this be done using a RequestFilter?
AntranigBasman: Well, that is one way
mjnsakai: It might be tricking knowing when it was supposed to kick in.
AntranigBasman: Yes
mjnsakai: Perhaps there is no way around it, tho. After all, RSF expects to work normally with the HTTP request cycle.
AntranigBasman: Well, I am just looking to see what beans it might be worth overriding, and whether this can be done stably
AntranigBasman: The only thing you might hope to gain is being able to have a bean which is aware of the current ViewParameters, rather than just the raw ServletRequest
mjnsakai: ah
AntranigBasman: How were you planning to know within an app, whether to send a request to a file, or whether to send it to HTTP?
mjnsakai: it would be a specific event. I'd transition to a produce that displays the result of the compile operation.\
mjnsakai: So the page is rendered as a side effect.
mjnsakai: Oh, I had an interesting thought. I could fire my own HTTP request to Sakai and gather the results.
AntranigBasman: You'd think
AntranigBasman: But no (tongue)
AntranigBasman: Don't even try that (tongue)
mjnsakai: (sad)
mjnsakai: why not?
AntranigBasman: I'll explain shortly
AntranigBasman: On a Skype call at present (tongue)
mjnsakai: infinite loops,perhaps.
mjnsakai: oh, sorry.
AntranigBasman: ok
mjnsakai: ..
AntranigBasman: Yes, it is virtually impossible to successfully "originate" requests into Sakai from inside it
AntranigBasman: For a whole host of reasons
mjnsakai: are they valid reasons?
AntranigBasman: The primary one being that many instances are hosted in such a way that prevent them from resolving their own public URLs
mjnsakai: ah, yes. I see that.
AntranigBasman: It sounds crazy, but it is a surprisingly common "enterprise" setup...
mjnsakai: So can I do this using RSF?
AntranigBasman: The chances don't look great, unfortunately
mjnsakai: How disapointing!
AntranigBasman: Look at the code, it calls "setupResponseWriter" as the very first line of "handleGet"
AntranigBasman: yes, it is a bit disappointing
AntranigBasman: I have been meaning to refactor this area for a while, since there are other cases this can be a dangerous behaviour too
AntranigBasman: Basically you would need to override the "RootHandlerBean" with your own one
AntranigBasman: But what is worse, you still wouldn't get access to the ViewParameters at the right time
AntranigBasman: So unfortunately I have to recommend that a RequestFilter is probably the best option for this
mjnsakai: arg.
mjnsakai: oh well.
AntranigBasman: At least you will be falling back on "tried and trusted" technologies (tongue)
mjnsakai: Can I make a request to add this support for RSF 1.0?
AntranigBasman: I have "half-made" this change a number of times
AntranigBasman: Since it looked like it was essential for some kinds of AJAX requests
AntranigBasman: But I always backed it out in the end
mjnsakai: I suspect there is more to it that just rendering, anyways.
mjnsakai: The URLs are likely wrong>
AntranigBasman: Well, RSF always renders with absolute URLs
AntranigBasman: Which perhaps is another "problem" for this use case
mjnsakai: Yes, but they reference the tool.
AntranigBasman: Yes
mjnsakai: I think I'd have to post process the results to cast the tool URLs to absolute ones.
mjnsakai: In the repository.
AntranigBasman: Hmm
AntranigBasman: Well, surely the producer should just be told which URls to use?
mjnsakai: Could be done.
mjnsakai: hmm
mjnsakai: Yes, it could be done that way.
mjnsakai: I'd have to conditionalize the code.
mjnsakai: Not too bad in the Sousa case, however.
AntranigBasman: What "are" the "repository" URLs anyway?
mjnsakai: It really only comes up with sequencing links.
AntranigBasman: You have some other set of "more durable" URLs?
mjnsakai: They are URLs into the CHS.
mjnsakai: stored media objects like an image.
AntranigBasman: Right
mjnsakai: I do this already, mostly.
AntranigBasman: Why aren't those the ones.... right
mjnsakai: Most of them are.
mjnsakai: Only the interactive ones would be broken, but they'd need to be handled some way anyways.
mjnsakai: It just needs more thinking.
mjnsakai: They key thing is that I'd like a way to compile a Sousa page, which is currently and XML file referring to many media objects.
AntranigBasman: I mean, you could actually get inside the guts and override the "setupResponseWriter" method in your custom override of RootHandlerBean
AntranigBasman: And replace it with a "lazy" instance that does not actually produce the POS until somebody first requests a write operation
AntranigBasman: Which would certainly be long after the ViewParameters were actually available
mjnsakai: bit of a hack, I suppose.
AntranigBasman: A bit, yes
mjnsakai: Which I am not beyond, as all know.
AntranigBasman: Still, RootHandlerBeanBase is a perfectly well-defined abstract class with a couple of abstract methods
AntranigBasman: There is for example the "test environment" which can be used for simply "bottling" the results of a render into a string
mjnsakai: that might do it.
mjnsakai: I just need a string to save.
AntranigBasman: The only issue is how you could configure this into your application "at the same time" as the HTTP environment
mjnsakai: heh
mjnsakai: yeah
AntranigBasman: One of the key deliverables for RSF 0.8 is to allow multiple configurations to coexist in the same webapp
AntranigBasman: Since this is really part of the Spring Web tech standard
mjnsakai: Keep this use case in mind, eh?
AntranigBasman: They have a "FrameworkServlet" which so far I have not been using
AntranigBasman: Yes
AntranigBasman: Feel free to JIRA it (tongue)
mjnsakai: where?
AntranigBasman: RSF JIRA
mjnsakai: ok