cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Hoskens>
Subject Re: Forms, writing extra info
Date Wed, 03 Nov 2004 12:44:19 GMT
If I leave out the old/new value test, it seems that it always gets saved.

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....

Kind Regards,

Joerg Heinicke wrote:

> On 03.11.2004 10:31, Jan Hoskens wrote:
>> 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.
> Joerg
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message