Bug with the incremental property ?

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

Bug with the incremental property ?

Lomobob
Hi all,

With orbeon PE 4.1, in form builder, I tried to use the incremental property to manipulate the content of an input field as the user types in it. I tried different manipulations, and every time, it appears that it works except in one case: when I press on a key until the repetition of the char occurs, then it doesn't work.

For example, here's a code that transforms the text in 'ok' if there are only [a-z] char, and 'try again' else :

<xf:input id="control-1-control" bind="control-1-bind" incremental="true">
      <xf:label ref="$form-resources/control-1/label"/>
      <xf:hint ref="$form-resources/control-1/hint"/>
      <xf:help ref="$form-resources/control-1/help"/>
      <xf:alert ref="$fr-resources/detail/labels/alert"/>
      <xf:action ev:event="xforms-value-changed">
            <xf:setvalue ref="instance('fr-form-instance')/section-1/control-1"                     
                      value="if (instance('fr-form-instance')/section-1/control-1[matches(.,'^[a-z]+$')]) then 'ok' else 'try ag4in'">
            </xf:setvalue>                                      
      </xf:action>
</xf:input>

When I press 'a' for a long time, the input takes the value 'aaaaaaaa' and doesn't change. I tried it with chrome (Version 26.0.1410.64 m) and firefox (21.0) up-to-date, for the same result.

Any idea ?

Lomobob

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Bug with the incremental property ?

Alessandro  Vernet
Administrator
Hi Lomobob,

Because of the way the XForms engine is working, this use case is not supported. Keep in mind that the XForms logic, in particular your xf:setvalue, is running on the server, while the browser is receiving input from the user. At a given point in time, the server can have a slightly outdated value of the field.

So, when the client (= browser) receives an update from the server, it checks if the user has made and changed that field since the value was sent to the server. If the user made a change, then the value coming from the server is discarded, as you wouldn't want to override a change made by the user done by the server based on outdated information.

This means that you should avoid having logic that relies on changing a form field while the user is editing that form field.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet