Hi, In the following example I've used 6 different ways of setting value into model node. Tests 1 and 5 works fine, but tests 2-4 and 6 does not. Even though the value is set (somewhere) in every situation and can be presented by xf:message action it is not available in current model (neither by any xforms control nor xforms-inspector).It looks like references to nodes were calculcated way before use and points at a node that is not in current model after xf:insert action. Fifth method could be a temporary solution for me but does not work when it is used inside dispatched custom event - test 6, and that's my case unfortunately.
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 view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/fdb44ac6-4165-4e64-bb18-41ca92ab1a63%40googlegroups.com. |
Hi, just for curiosity, I run the code and check if it is possible to fix it. It was possible by adding binds and a reference to xf:message via bind="bind-id" instead of ref. Of course, it's not an explanation, but I also have experience with delay in recalculation when use ref attribute. BR, //Jarek See working code below: <xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fr="http://orbeon.org/oxf/xml/form-runner"> <xh:head> <xh:title>insert and setvalue</xh:title> <xf:model> <xf:instance id="main"> <root xmlns=""> <entry>Initial value</entry> </root> </xf:instance> <xf:instance id="copy"> <root xmlns=""> <entry/> </root> </xf:instance> <xf:bind id="main-bind" ref="instance('main')"> <xf:bind id="entry-bind" ref="entry"/> </xf:bind> </xf:model> </xh:head> <xh:body> <xh:p> <xf:group ref="instance('main')/entry" id="group"> <xf:trigger> <xf:label>Test 6</xf:label> <xf:action ev:event="DOMActivate"> <xf:dispatch target="group" name="custom-event" /> </xf:action> </xf:trigger> <xf:action ev:event="custom-event"> <xf:action> <xf:var name="param" value="." /> <xf:insert origin="instance('copy')" ref="instance('main')" /> <xf:setvalue ref="instance('main')/entry" value="now()" /> <xf:rebuild/> </xf:action> <xf:action> <xf:message bind="entry-bind" /> </xf:action> </xf:action> </xf:group> </xh:p> <xh:p> <xf:output value="if (normalize-space(/root/entry) = '') then '' else concat('Not empty: ', /root/entry, '!')"/> </xh:p> <fr:xforms-inspector /> </xh:body> </xh:html> śr., 30 paź 2019 o 13:04 Sławomir Kisiel <[hidden email]> napisał(a):
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 view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/CAHFpwcWzvcSAht04iS%2BbF4KCfZzA5yYhrsV4Dq7hgZyhjtkkNA%40mail.gmail.com. |
Hi, Unfortunately xf:bind has some disadvantage that bothers me. It does not work well with repeats because it always goes through first nodes. Ref's works better in such case but worse in case of inserting instance.W dniu piątek, 1 listopada 2019 15:40:08 UTC+1 użytkownik Jarek napisał:
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 view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/5c88a93a-25be-4a9e-8a10-061abd0dd43e%40googlegroups.com. |
Not sure what your exact case is but code below works as expected (paste it directly into xh:body). You can add a new entry and edit it. <xf:trigger> <xf:label>Add item</xf:label> <xf:action ev:event="DOMActivate"> <xf:insert origin="instance('copy')/entry" ref="instance('main')/entry" /> </xf:action> </xf:trigger> <xf:repeat bind="entry-bind"> <xf:input ref="."> <xf:label>My entry</xf:label> </xf:input> </xf:repeat> //Jarek pt., 1 lis 2019 o 16:06 Sławomir Kisiel <[hidden email]> napisał(a):
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 view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/CAHFpwcXHyUer66CAtk6Jzq5W0K8c5KWr0_YL3AizDydqe55axQ%40mail.gmail.com. |
Administrator
|
In reply to this post by jaygo
Hi,
Interesting cases. It looks like things are not working as they should, but, in fact, they do ;). Let's go through it: 1) "test 1" is set in the instance and shows in the message, good. 2) Actions evaluate in a certain context. Since you have an `<xf:action ev:event="DOMActivate">` inside a `<xf:trigger>`, the context is the node the trigger is bound to, which in your case is `/root/entry` of the first `main` instance. You start by doing a `<xf:insert origin="instance('copy')" ref="instance('main')"/>`. When you do an insert with a `ref` pointing to the root element if the instance, it replaces that element. That is the interesting part: after the insert, `instance('main')` contains a new copy of `instance('copy')`, which looks exactly the same, but is a different copy. Meanwhile, the context isn't changed: it just points to a node that now isn't reachable through an instance, and thus will be garbage collected if not inserted somewhere before the end of the action. So now you `<xf:setvalue ref="../entry" value="'test 2'"/>`, which sets the value in that "detached" tree. `<xf:message value="../entry"/>` shows the value you inserted, but at the end that value isn't in `instance('main')`. 3) This behaves the same as the previous one even if you have a separate event handler. This is because the node the `<xf:trigger>` is bound to isn't reevaluate between event dispatches; it is only reevaluate when the UI is refreshed. 4) The `<xf:refresh/>` does reevaluate the node bound to the `<xf:trigger>`, but the action is still running, so it keeps it current context (the "detached node"). 5) This one works, because you have a different event handler, which takes the new context of the `<xf:trigger>`, which has been reevaluated by your `<xf:refresh/>`. 6) Is equivalent to 4. And of course, just let me know if anything isn't clear, or this doesn't give you enough information to solve the actual case you are dealing with. ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1572892915468-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Administrator
|
Hi Sławomir, did you finally manage to do what you were looking for,
inserting a subtree in your instance needed? And of course, just let me know if anything in the use cases you mentioned still doesn't make sense. ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1573495138084-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |