Event on autocomplete while loading a form with repeated items

100 views
Skip to first unread message

Heinrich Götzger

unread,
Jan 27, 2017, 6:06:30 PM1/27/17
to orb...@googlegroups.com
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

Heinrich Götzger

unread,
Jan 30, 2017, 10:32:36 AM1/30/17
to orb...@googlegroups.com
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

Alessandro Vernet

unread,
Jan 31, 2017, 1:46:58 AM1/31/17
to orb...@googlegroups.com
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
--
View this message in context: http://discuss.orbeon.com/Event-on-autocomplete-while-loading-a-form-with-repeated-items-tp4662148p4662161.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

Heinrich Götzger

unread,
Jan 31, 2017, 9:36:18 AM1/31/17
to orb...@googlegroups.com
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

Alessandro Vernet

unread,
Jan 31, 2017, 12:48:48 PM1/31/17
to orb...@googlegroups.com
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
--
View this message in context: http://discuss.orbeon.com/Event-on-autocomplete-while-loading-a-form-with-repeated-items-tp4662148p4662169.html

Heinrich Götzger

unread,
Feb 3, 2017, 12:33:27 PM2/3/17
to orb...@googlegroups.com
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.

loadAc.xhtml

Alessandro Vernet

unread,
Feb 3, 2017, 7:24:06 PM2/3/17
to orb...@googlegroups.com
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
--
View this message in context: http://discuss.orbeon.com/Event-on-autocomplete-while-loading-a-form-with-repeated-items-tp4662148p4662193.html

Heinrich Götzger

unread,
Feb 6, 2017, 12:17:18 AM2/6/17
to orb...@googlegroups.com
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

Alessandro Vernet

unread,
Feb 6, 2017, 7:39:45 PM2/6/17
to orb...@googlegroups.com
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

--
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 orbeon+unsubscribe@googlegroups.com.
To post to this group, send email to orb...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages