Everything works fine with the function.
I've been able to retrieve my xml and to fetch the required node.
Problem, I can't fetch any nodeValue.
To check, I save the node.nodeValue content in a session attribute and try
to get this attribute content back to the browser. Each time I get an empty
result.
If I ask for the nodeName or node attribute, I get the required result. It
only fails with nodeValue or data.
Here's my flowscript, based on the link you sent to me. Hopefully you know
what I'm doing wrong :
// loadDocument() reads in an XML file and returns a DOM Document.
function loadDocument(uri) {
var parser = null;
var source = null;
var resolver = null;
try {
parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
source = resolver.resolveURI(uri);
var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
is.setSystemId(source.getURI());
return parser.parseDocument(is);
} finally {
if (source != null) resolver.release(source);
if (parser != null) cocoon.releaseComponent(parser);
if (resolver != null) cocoon.releaseComponent(resolver);
}
}
function getCaptchaUserEntry() {
// retrieve the XML
var xml = loadDocument("cocoon:/get-stream");
// get the root element:
var root = xml.getDocumentElement();
// get captcha elements (actually only 1 captcha element is allowed in the
xforms)
var captchaUserEntries = root.getElementsByTagName("captcha");
// get captcha node
for (var i = 0; i < captchaUserEntries.getLength(); i++) {
var captchaUserEntry = captchaUserEntries.item(i);
}
// get required content
var captchaUserContent = captchaUserEntry.nodeValue;
// save in session - to debugg
var session = cocoon.session;
session.setAttribute("captcha-result", captchaUserContent);
// ---------------------------
var parameters = null;
parameters = {
"captcha-result": captchaUserContent,
};
cocoon.sendPage("check-session", parameters);
}
Thanks,
Josh
--
View this message in context:
http://www.nabble.com/How-to-get-same-function-as-java-loadDocument%28cocoon%3A-your.pipeline%29-in-javascript-flow--tf4581000.html#a13081947
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]