On 03.07.2004 17:00, Colin Paul Adams wrote:

I'm trying to do this, but I'm running into real problems.
The Mozilla javascript console shows nothing.

This is server side javascript, it can not end in Mozilla js console.

     <fb:javascript id="id" path="count(preceding::sibling[local-name() = 'event']) + 1" 
direction="load">
        <fb:load-form>
          var appValue = java.lang.StrictMath.floor (jxpathPointer.getValue());
          var formValue = new java.lang.Double (appValue);
          var longValue = new java.lang.Long (formValue.longValue());
          widget.setValue (longValue);
        </fb:load-form>
      </fb:javascript>

Why I don't know

It's wrong. @path refers to "where to get/set the value".

- nor how to debug it,

That's indeed difficult. Only help is the usage of print().

but the XPath expression is correct, I think

No. preceding::sibling[local-name() = 'event'] should read preceding-sibling::*[local-name() = 'event'].


On the documentation page, the example shows use of a function
doLoadConversion(),

Don't know about it.

The code should be something like:

<fb:javascript id="id" path="@id" direction="save">
<fb:save-form>
var appValue = jxpathPointer.getValue();
if (appValue == '') {
var precSiblId = jxpathContext.getValue("../preceding-sibling::contact/@id");
var newId = Number(precSiblId) + 1
jxpathPointer.setValue(newId.toFixed(0));
}
</fb:save-form>
</fb:javascript>


This works for me. I committed it to CVS for the first XML binding sample.

Joerg


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



Reply via email to