On Mar 11, 2004, at 2:35 PM, JD Daniels wrote:
I am getting closer...
using the v2 flow api:
That's the spirit! :-)
I was going to suggest that, but hadn't gotten around to it. Nice to see you chose that way.
model.inventory.onAddRow = function(row) {
var uri = "cocoon:/load-InventoryItem?id=" + model.inventoryId.value;
var resolver = cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE);
var source = resolver.resolveURI(uri);
var parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
var document = parser.parseDocument(Packages.org.apache.cocoon.components.source.SourceUtil.getInputSource(source));
//How do I give the row widgets the value of the xml nodes in the dom document here?
}
A couple of observations (I'm a newbie too, BTW, so my high-horse isn't so high... :-):
1) If it were me, and parsing a DOM tree were going to be part of this deal, then I would immediately switch to Java for that part — encapsulate it in a Java class and give myself a nice method or two to call from the flowscript. You're basically programming in Java here, with the Java code hoisted up into the flowscript anyway, but that's not really the right idiom for flow IMHO. Maybe it's just a matter of taste, I don't know. To me, parsing a DOM tree is not something that should be exposed in the presentation layer.
2) If I were going to do this for some reason, I don't think I'd do it right there in the onAddRow function. I'd do it in the setup (and then maybe use org.apache.xpath.XPathAPI where I needed it, like in this function...)
3) BUT — and this is the big one I think — Why not skip the whole XSP-generating-XML-from-model-data part of this plumbing, and just access your business objects directly from the flow? (Or am I mis-reading between the lines here?)
(Note, I'm kinda biased against XSP anyway, since it's on the outs and I never learned it anyway... jumped right into flow+Java when I started w/ Cocoon)
I think (3) hopefully answers your question, that's the idea anyway ("Doc, it hurts when I do this"... "Well, don't do that!" :-)
Best Regards,
Mark
