Event on autocomplete while loading a form with repeated items

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

Event on autocomplete while loading a form with repeated items

Heinrich Götzger
Hoi,

game is going on. I'm still working on filling autocomplete-components.

Handling the copy-event is working as described with the drawback that it's iterating over the complete set on every copy-event.

But now I'm working on the form-loading-task, and I can't find a way to populate an event into the table to get the fr-set-label-event fired so that the autocomplete-component got updated.

I tried to call in the xforms-ready but it seems that it's not finding the targetid="Item_TXT". Populating an event into the fr-table is possible, but still it's not going into the repeat over the item list.


Is this problem understandable?

Thanks for some help.

Kind regards

Heinrich

--
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: Event on autocomplete while loading a form with repeated items

Heinrich Götzger
Hoi,

I tried following within the table-elements for the fr-datatable:

    <xf:action
          ev:event="xforms-enabled" phase="target"
          xxf:iterate="instance('content')/InvoiceItems/item">

          <xf:message value="concat(' xforms-enabled ', position(), '
[', TXT, ']')"/>

          <xf:send submission="get-TXTItem-submission">
             <xf:property
                name="txt"
                value="TXT"/>
          </xf:send>

          <xf:dispatch
             xxf:repeat-indexes="{position()}"
             targetid="Item_TXT"
             name="fr-set-label">
             <!-- write label from rest-server into field -->
             <xf:property
                name="label"
                value="instance('submission')/txt/item/label"/>
          </xf:dispatch>

          <xf:message value="concat('submission: [', TXT, '] ==> [',
instance('submission')/txt/item/label, ']')"/>

    </xf:action>


All my messages appear as expected, but the autocomplete-component is
not being updated.

Still not getting the correct target/position for some reason.

Any ideas?

Thanks and Cheers

Heinrich

--
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: Event on autocomplete while loading a form with repeated items

Alessandro  Vernet
Administrator
Hi Heinrich,

Let's see if we can tackle this one in a different way. Are you using the autocomplete in resource mode? Setting the label can like this can cause performance problems, can be highly inefficient; instead could you use the `labelref="…"` on the autocomplete?

https://doc.orbeon.com/form-runner/component/autocomplete.html#resource

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Event on autocomplete while loading a form with repeated items

Heinrich Götzger
Hoi Alex,

yes, autocomplete is in resource mode:

         <fr:autocomplete
            id="Item_TXT"
            ref="TXT"
            labelref="VTEXT"
            resource="{$rest_api}/txt/all?query={normalize-space(encode-for-uri($fr-search-value))}&amp;maxResults={$maxResults}"
            show-suggestions-button="false">
            <fr:max-results-displayed ref="$maxResults"/>
            <xf:itemset ref="item">
               <xf:label ref="label"/>
               <xf:value ref="value"/>
            </xf:itemset>
         </fr:autocomplete>


While loading the form, I iterate over the items and trigger the submission as last action in xforms-ready for the non empty TXT elements:

         <xf:send submission="get-TXTItem-submission">
            <xf:property
               name="txt"
               value="TXT"/>
         </xf:send>

         <xf:setvalue
            ref="VTEXT"
            value="instance('submission')/txt/item/label"/>

But unfortunately, label is not showing up, the label is not in VTEXT as well, has never been. I think I tried this earlier in some ways.

If this would work, I probably could write the label in VTEXT while creating the xml-form-data and load the form without using the rest-service at all. Best solution in my eyes.

We're using Orbeon Forms 4.5.0.201404080036 CE if this is important.



Thanks and cheers

Heinrich

--
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: Event on autocomplete while loading a form with repeated items

Alessandro  Vernet
Administrator
Hi Heinrich,

If in "resource mode", and you have the label in the instance, then we'd like the `labelref` to work, because if you dispatch an `fr-set-label`, in addition to making your code more complicated, the service will be called, which isn't good for performance.

Could you create a minimal example that I can run here that shows the `labelref` not working on page load, check that this example also doesn't work with 2016.3, and share it with us?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Event on autocomplete while loading a form with repeated items

Heinrich Götzger
Hoi Alex,

working 'labelref' would be fine and would be probably be the natural
solution.

An example 'loadAc.xhtml' (minimal?) is attached to this mail. I'm not
100% sure if all is correct in it, please correct if not.

I tried with orbeon-2016.3.201612302139-CE and with Orbeon Forms
4.5.0.201404080036 CE without success.

Thanks for taking a look at it.

Cheers

Heinrich

--
Before printing this e-mail, think about our environmental responsibility.

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

loadAc.xhtml (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Event on autocomplete while loading a form with repeated items

Alessandro  Vernet
Administrator
Hi Heinrich,

Got it: this is because `labelref` is relative to the node the control is bound to (with `ref` or `bind`). In your case, the autocomplete's input is properly populated if you use: `labelref="../VTEXT"`.

The documentation didn't say this, so you couldn't have guessed! I added a line about this to the doc. (If you create a form with Form Builder, it sets the `labelref` properly, so most people using the autocomplete didn't need to worry about it.)

You'll let me know if this is enough to solve the problem.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Event on autocomplete while loading a form with repeated items

Heinrich Götzger
Hoi Alex,

a first glance in the example looks very good! Thanks for taking your time on this issue!

I'll clean up my forms and let you know about the result.

Cheers

Heinrich

--
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: Event on autocomplete while loading a form with repeated items

Alessandro  Vernet
Administrator
Hi Heinrich,

Excellent, and you'll let us know how it works out. And thank you for giving us an opportunity to improve the documentation :).

Alex

On Sun, Feb 5, 2017 at 9:17 PM, Heinrich Götzger <[hidden email]> wrote:
Hoi Alex,

a first glance in the example looks very good! Thanks for taking your time on this issue!

I'll clean up my forms and let you know about the result.

Cheers

Heinrich

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

--
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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet