First I changed a line in the function createBean() in my flowscript the former line was:
bean = parser.parseDocument(is).getDocumentElement(); now, there is bean = parser.parseDocument(is); to obtain the full XML document. I added /root in <fb:context/>. My binding file is now: <?xml version="1.0"?> <fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" path="/root"> <fb:value id="number" path="beannumber"> <fd:convertor datatype="long"/> </fb:value> </fb:context> My data file is: <?xml version="1.0"?> <root> <beannumber>5</beannumber> </root> The form.load(bean) is pretty good, but I don't know how to get the value of the bean after form.save(bean). bean.getElementsByTagName("beannumber") returns a DeepNodeList-Object. I get an object Node() via the method item() of the class DeepNodeListImpl. var number = bean.getElementsByTagName("beannumber"); var tmp = number.item(0); tmp is now an object of type Node(). When I say tmp.getNodeName() I get "beannumber". (that's correct) When I say tmp.getNodeValue I get "null". How can I receive the value of my bean? Thanks Saskia -------- Original-Nachricht -------- Datum: Tue, 8 Aug 2006 09:18:04 +0200 Von: "Ard Schrijvers" <[EMAIL PROTECTED]> An: [email protected] Betreff: RE: Access to XML bean elements in flowscript/javaflow > But I still think, as what Dennis already pointed out, is that your > binding path is incorrect or did you change it? If you still have > > <?xml version="1.0"?> > <fb:context > xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" > xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" > path="/"> > <fb:value id="number" path="beannumber"> > <fd:convertor datatype="long"/> > </fb:value> > </fb:context> > > Then the path won't match /root/beannumber. either add /root to the > fb:context path or use in fb:value something like /root/beannumber > > Regards Ard > > > > > > > you are right, it's an DOM object. However, I tried > > getElementByTagName(), but I didn't get any output. > > > > Below is the the entire flowscript: > > > > cocoon.load( > > "resource://org/apache/cocoon/forms/flow/javascript/Form.js"); > > > > function square() { > > var form = new Form("fields.xml"); > > form.createBinding("binding.xml"); > > var quadrat; > > > > var bean = createBean(); > > form.load(bean); > > form.showForm("formtemplate-page"); > > form.save(bean); > > var number = bean.getElementsByTagName("beannumber"); > > var square = number * number; > > cocoon.sendPage("result-page", {"square" : square}); > > } > > > > function createBean() { > > var file = "data.xml"; > > var bean = null; > > var source = null; > > var resolver = null; > > var parser = null; > > try { > > resolver = cocoon.getComponent( > > Packages.org.apache.cocoon.environment.SourceResolver.ROLE); > > source = resolver.resolveURI(file); > > var is = new > > Packages.org.xml.sax.InputSource(source.getInputStream()); > > is.setSystemId(source.getURI()); > > parser = cocoon.getComponent( > > Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE); > > > > bean = parser.parseDocument(is).getDocumentElement(); > > } finally { > > if (source != null) { > > resolver.release(source); > > } > > cocoon.releaseComponent(parser); > > cocoon.releaseComponent(resolver); > > } > > return bean; > > } > > > > This is my data.xml file: > > > > <?xml version="1.0"?> > > > > <root> > > <beannumber>5</beannumber> > > </root> > > > > Thanks in advance > > > > Saskia > > > > -------- Original-Nachricht -------- > > Datum: Mon, 7 Aug 2006 10:10:29 -0700 > > Von: Mark Lundquist <[EMAIL PROTECTED]> > > An: [email protected] > > Betreff: Re: Access to XML bean elements in flowscript/javaflow > > > > > > > > On Aug 7, 2006, at 10:00 AM, Ard Schrijvers wrote: > > > > > > > That's what I meant: if the bean is a dom --> > > > > bean.getElementsByTagName("foo") > > > > > > > > and I wrote that my former "bean.lookupWidget" should be > > replaced by > > > > "form.lookupWidget" > > > > > > Ah, I get it... you weren't answering his question of how to access > > > something in 'bean' (whatever that is :), rather you were > > suggesting > > > the alternative of querying the form widget value itself > > (from which > > > the bean property should have been set by the binding > > save()). Is that > > > right? > > > > > > That would have the disadvantage that the form widget.value is a > > > String, whereas the bound object property will have been > > converted by > > > some Converter to its proper datatype. > > > > > > Anyway another poster said that the OP's binding was wack, so maybe > > > that will turn out to be his problem. > > > > > > peace, > > > —ml— > > > > -- > > > > > > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
