Hi Saskia,

On Aug 8, 2006, at 12:01 PM, Saskia Heesen wrote:

At the beginning the function createBean() reads the XML document data.xml. The value of the bean element beannumber is 5. The bean is transfered to the widget by form.load(bean). At the HTML page, the widgets starts with the value of 5. So, I think the binding at the beginning is ok.

Right.

When I submit the HTML form without any change of the widget as a user, I think after a form.save(bean) the value of the bean element must still be 5. I am wondering how the value changes to null.

Well, if you are not doing anything after the form.save(), then the value is probably not changing after the save... the save must be botching somehow, i.e. the save() itself nulling out the element. A good experiment would be to comment out the save() and then query the DOM bean just as before. If you're interrogating the bean correctly, and the value is still '5' after the form is submitted and you have the save() commented out, but then it goes to 'null' when you un-comment the save(), that says that either (a) something is screwing up the save(), or (b) the form submission request is not as you expect w.r.t. this form parameter/value (that's why I suggested HTTPLiveHeaders before). A variation on this is to keep the save(), but change the binding to have direction="load".

Using JXPath is a good idea, but what kind of classes or methods do I have to use.

I guess it would be

        importClass Packages. org.apache.commons.jxpath.JXPathContext;
        .
        .
        .
        print (JXPathContext.newContext(bean).getValue ('/root/beannumber'));

Another point is, that the binding framework should provide the correct datatype. When I get the value of an XML node, for example 5, I don't know if 5 is a string, an integer, or a long. By using JavaBeans or JavaScript Beans, I get the right datatype, a conversion is not necessary. Can this achived for a XML bean, too? In my XML books I was told that besides an XML binding file a schema or a dtd is necessary to get the right datatype.

Well, that all depends on what the consumer of the XML wants.

But I don't know how a schema can be integrated into the cocoon binding framework.

No clue, except that it probably wouldn't involve the binding framework at all. Remember, you are binding to a DOM object to begin with, and if that DOM already has a DOCTYPE, the binding framework is unaware of that and won't change it (it doesn't create a new DOM object, it uses JXPath to manipulate the one you bound), which is what you want (the form changes the data, not the schema).

HTH,
—ml—


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to