Joerg Heinicke wrote:
On 03.11.2004 13:44, Jan Hoskens wrote:
If I leave out the old/new value test, it seems that it always gets saved.
That might be a different behaviour between binding to beans and XML. Don't know exactly though.
You mention event listeners/widgets. These are coupled to the form in flowscript or in the form definition (if I'm correct that is ;-) ). On that moment there's no connection with the data source. So I would have to create additional changed widgets for each value in order to set their value through a listener widget? The given code will set attributes (@changed) directly in the data source without a connection through a form widget.
I'm not quite sure what you're meaning....
Yes, I meant additional widgets. Like myvalue and myvalue-changed, where myvalue-changed is set to true by the value-changed listener on myvalue. I guess it is a decision between more complex forms/easier JS in binding and easier forms/more complex JS in binding.
Ok, got it.
I'll have to look into it a bit deeper to find out which way to go. (I'll definitely keep that listener method in mind.;-))
Thanks Joerg.
Jan
Joerg
I have several cforms that connect to xml documents. These may contain default values. If a user changes a value, an attribute changed will be set on that value-element and on the document-element. To accomplish this, I have to set javascript bindings for each value looking like:
<fb:javascript id="myvalue" path="myvalue">
<fb:load-form>
widget.setValue(jxpathPointer.getValue());
</fb:load-form>
<fb:save-form>
var formValue = widget.getValue() == null ? new java.lang.String(""): new java.lang.String(widget.getValue());
if ( !jxpathPointer.getValue().equals(formValue)){
jxpathPointer.setValue(formValue); jxpathContext.createPathAndSetValue("@changed", "true");
jxpathContext.createPathAndSetValue("/document_root/@changed", "true");
}
</fb:save-form>
</fb:javascript>
Is there a better way to do the same?
AFAIK the binding itself happens only on change, so you don't need to test for value change. So for updating the value and adding @changed you probably only need two binding specifications (without any JS/JXPath). It gets more complicated if you need the additional /document_root/@changed. But I would definitely move this out of binding into form logic, i.e. form definition. You can use some value-changed-listener-widgets, so you don't need to work with JXPath in JS at least.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
