Behaviour of xforms:bind

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Behaviour of xforms:bind

idwright
Hi,

I'm seeing some strange behaviour with xforms:bind

The scenario is that I have 2 xforms:select1 controls - tradeName and
manufacturer - if I know the tradeName then I know the manufacturer - so
far so good
However if I don't know the tradeName ('Other') then I want to be able
to select from the list of manufacturers - again not too bad

The problem arises when I select 'Other' for tradeName - the
manufacturer list is not enabled until I save; i.e. the nodeset on the
bind is not recalculated until after the save - I guess this is because
it's looking at a different node during the evaluation of the [] so
manufacturer hasn't changed but tradeName has - but once the nodeset has
been evaluated it doesn't seem to change behaviour until it's saved i.e.
won't switch between calcuate mode and not calculate mode.

likewise if I switch from Other to something else then the calculation
does not occur until after I've saved (so actually have to save again
after that to ensure that the calculated value is saved)

<tradeName></tradeName>
<manufacturer></manufacturer>


<xforms:bind nodeset="manufacturer[not(../tradeName = 'Other')]"
                                             calculate="
                                             for $currentItemName in
../tradeName return
xxforms:instance('all-resources')//manufacturer[@tradeName =
$currentItemName]
                                             " />


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of xforms:bind

Erik Bruchez
Administrator
Ian,

This looks like a case of "dynamic dependencies" in binds.

Bind nodesets are computed at a specific time, the so-called model
rebuild. Outside of a rebuild, the binds nodesets remain the same.
When this happens, running the xforms:rebuild action at the right time
will fix things. You might want to try that.

-Erik

On Thu, Dec 1, 2011 at 1:28 AM, Ian Wright <[hidden email]> wrote:

> Hi,
>
> I'm seeing some strange behaviour with xforms:bind
>
> The scenario is that I have 2 xforms:select1 controls - tradeName and
> manufacturer - if I know the tradeName then I know the manufacturer - so far
> so good
> However if I don't know the tradeName ('Other') then I want to be able to
> select from the list of manufacturers - again not too bad
>
> The problem arises when I select 'Other' for tradeName - the manufacturer
> list is not enabled until I save; i.e. the nodeset on the bind is not
> recalculated until after the save - I guess this is because it's looking at
> a different node during the evaluation of the [] so manufacturer hasn't
> changed but tradeName has - but once the nodeset has been evaluated it
> doesn't seem to change behaviour until it's saved i.e. won't switch between
> calcuate mode and not calculate mode.
>
> likewise if I switch from Other to something else then the calculation does
> not occur until after I've saved (so actually have to save again after that
> to ensure that the calculated value is saved)
>
> <tradeName></tradeName>
> <manufacturer></manufacturer>
>
>
> <xforms:bind nodeset="manufacturer[not(../tradeName = 'Other')]"
>                                            calculate="
>                                            for $currentItemName in
> ../tradeName return
> xxforms:instance('all-resources')//manufacturer[@tradeName =
> $currentItemName]
>                                            " />
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Behaviour of xforms:bind

idwright
Erik,
Thanks for the reply - that very nearly worked.

I do have it working now - I've written this up in a bit more detail as
part of a larger post at
http://aelfric.co.uk/random/2011/12/xforms-select-using-an-xml-schema-xsd/ 
- however, for reference, see below for a short summary about how I got
it working

What I tried was:
<xforms:select1 appearance="minimal" ref="name">
     ....
<xforms:action ev:event="xforms-value-changed">
<xforms:rebuild model="mod-study-dashboard" />
</xforms:action>
</xforms:select1>

This did trigger the rebuild however the evaluation of the bind appears
to be done on the value of name prior to the change instead of the value
after the change. (Putting a message into the action indicates that the
value had changed at that point so it's a bit confusing....)

I discovered that what works is to change a bit bucket instance
(<xforms:insert ref="instance('binding-control')//rebuild"
value="something"/>) instead which seems to trigger the rebuild at the
right time

Thanks,
Ian
On 19:59, Erik Bruchez wrote:

> Ian,
>
> This looks like a case of "dynamic dependencies" in binds.
>
> Bind nodesets are computed at a specific time, the so-called model
> rebuild. Outside of a rebuild, the binds nodesets remain the same.
> When this happens, running the xforms:rebuild action at the right time
> will fix things. You might want to try that.
>
> -Erik
>
> On Thu, Dec 1, 2011 at 1:28 AM, Ian Wright<[hidden email]>  wrote:
>> Hi,
>>
>> I'm seeing some strange behaviour with xforms:bind
>>
>> The scenario is that I have 2 xforms:select1 controls - tradeName and
>> manufacturer - if I know the tradeName then I know the manufacturer - so far
>> so good
>> However if I don't know the tradeName ('Other') then I want to be able to
>> select from the list of manufacturers - again not too bad
>>
>> The problem arises when I select 'Other' for tradeName - the manufacturer
>> list is not enabled until I save; i.e. the nodeset on the bind is not
>> recalculated until after the save - I guess this is because it's looking at
>> a different node during the evaluation of the [] so manufacturer hasn't
>> changed but tradeName has - but once the nodeset has been evaluated it
>> doesn't seem to change behaviour until it's saved i.e. won't switch between
>> calcuate mode and not calculate mode.
>>
>> likewise if I switch from Other to something else then the calculation does
>> not occur until after I've saved (so actually have to save again after that
>> to ensure that the calculated value is saved)
>>
>> <tradeName></tradeName>
>> <manufacturer></manufacturer>
>>
>>
>> <xforms:bind nodeset=anufacturer[not(../tradeName = 'Other')]"
>>                                             calculate=
>>                                             for $currentItemName in
>> ../tradeName return
>> xxforms:instance('all-resources')//manufacturer[@tradeName>  $currentItemName]
>>                                             " />
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing
>> list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=lp
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Behaviour of xforms:bind

Erik Bruchez
Administrator
Ian,

Great, thanks for sharing.

-Erik

On Fri, Dec 9, 2011 at 12:23 AM, Ian Wright <[hidden email]> wrote:

> Erik,
> Thanks for the reply - that very nearly worked.
>
> I do have it working now - I've written this up in a bit more detail as part
> of a larger post at
> http://aelfric.co.uk/random/2011/12/xforms-select-using-an-xml-schema-xsd/ -
> however, for reference, see below for a short summary about how I got it
> working
>
> What I tried was:
> <xforms:select1 appearance="minimal" ref="name">
>    ....
> <xforms:action ev:event="xforms-value-changed">
> <xforms:rebuild model="mod-study-dashboard" />
> </xforms:action>
> </xforms:select1>
>
> This did trigger the rebuild however the evaluation of the bind appears to
> be done on the value of name prior to the change instead of the value after
> the change. (Putting a message into the action indicates that the value had
> changed at that point so it's a bit confusing....)
>
> I discovered that what works is to change a bit bucket instance
> (<xforms:insert ref="instance('binding-control')//rebuild"
> value="something"/>) instead which seems to trigger the rebuild at the right
> time
>
> Thanks,
> Ian
>
> On 19:59, Erik Bruchez wrote:
>>
>> Ian,
>>
>> This looks like a case of "dynamic dependencies" in binds.
>>
>> Bind nodesets are computed at a specific time, the so-called model
>> rebuild. Outside of a rebuild, the binds nodesets remain the same.
>> When this happens, running the xforms:rebuild action at the right time
>> will fix things. You might want to try that.
>>
>> -Erik
>>
>> On Thu, Dec 1, 2011 at 1:28 AM, Ian Wright<[hidden email]>
>>  wrote:
>>>
>>> Hi,
>>>
>>> I'm seeing some strange behaviour with xforms:bind
>>>
>>> The scenario is that I have 2 xforms:select1 controls - tradeName and
>>> manufacturer - if I know the tradeName then I know the manufacturer - so
>>> far
>>> so good
>>> However if I don't know the tradeName ('Other') then I want to be able to
>>> select from the list of manufacturers - again not too bad
>>>
>>> The problem arises when I select 'Other' for tradeName - the manufacturer
>>> list is not enabled until I save; i.e. the nodeset on the bind is not
>>> recalculated until after the save - I guess this is because it's looking
>>> at
>>> a different node during the evaluation of the [] so manufacturer hasn't
>>> changed but tradeName has - but once the nodeset has been evaluated it
>>> doesn't seem to change behaviour until it's saved i.e. won't switch
>>> between
>>> calcuate mode and not calculate mode.
>>>
>>> likewise if I switch from Other to something else then the calculation
>>> does
>>> not occur until after I've saved (so actually have to save again after
>>> that
>>> to ensure that the calculated value is saved)
>>>
>>> <tradeName></tradeName>
>>> <manufacturer></manufacturer>
>>>
>>>
>>> <xforms:bind nodeset=anufacturer[not(../tradeName = 'Other')]"
>>>
>>>                                            calculate=
>>>                                            for $currentItemName in
>>> ../tradeName return
>>> xxforms:instance('all-resources')//manufacturer[@tradeName>
>>>  $currentItemName]
>>>
>>>                                            " />
>>>
>>>
>>> --
>>> You receive this message as a subscriber of the [hidden email] mailing
>>> list.
>>> To unsubscribe: mailto:[hidden email]
>>> For general help: mailto:[hidden email]?subject=lp
>>>
>>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws