Re: [Xsltforms-support] Cancelling loop/action
Brought to you by:
alain-couthures
From: Alain C. <ala...@ag...> - 2021-02-13 16:52:16
|
<!doctype html> <html> <head> <meta charset="UTF-8"> </head> <body> <div> Hi Josselin, </div> <div class="default-style"> <br> </div> <div class="default-style"> In this test case, an event is defined so two submissions are to be sent synchronously, one after one, according to a condition which should be true for one only. The first one will send again the same event producing a submission loop effect. But the first one is also altering the loop condition and it appears that, at the end, the 2 submissions are sent for the same event just before the latest event being caught. </div> <div class="default-style"> <br> </div> <div class="default-style"> The easiest way to control this is to invert the order of the submissions: the one to be activated at the end is to be tested <span style="text-decoration: underline;">before</span> the one to be activated repeatedly. </div> <div class="default-style"> <br> </div> <div class="default-style"> <div> <xf:action ev:event="submission"> </div> <div> <xf:send if="not(instance('sub')/xpr:person[@localType='new'])" submission="submitBio"/> </div> <div> <xf:send if="instance('sub')/xpr:person[@localType='new']" submission="submitNewPerson"/> </div> <div> </xf:action> </div> <div> <br> </div> </div> <div class="default-style"> Thank you for your feedback! </div> <div class="default-style"> <br> </div> <div class="default-style"> --Alain </div> <blockquote type="cite"> <div> Le 06/02/2021 14:42, Josselin Morvan <mor...@gm...> a écrit : </div> <div> <br> </div> <div> <br> </div> <div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" dir="auto"> Hi Steven, Hi Alain, <div class=""> <br class=""> </div> <div class=""> I made a short and simple sample to show you how my form works, what it does, and the error I get with the submission. </div> <div class=""> <br class=""> </div> <div class=""> Because I run it with BaseX, I added a little Xquery script that creates the db and allows the saving of the submissions. </div> <div class=""> If you want to use it, just put the form file into basex/webapp/static folder and the Xquery file into basex/webapp/ folder. It is a little REST application, just run basexhttp, then go to <a class="" href="http://localhost:8984/xforms/install">http://localhost:8984/xforms/install</a> to create the db, and to <a class="" href="http://localhost:8984/static/xsltforms/submissionLoop.xml">http://localhost:8984/static/xsltforms/submissionLoop.xml</a> to access the form. </div> <div class=""> <br class=""> </div> <div class=""> You can access the files on my Github Gist : <a class="" href="https://gist.github.com/sardinecan/64451cf122095178159804e1ea13b4e5">https://gist.github.com/sardinecan/64451cf122095178159804e1ea13b4e5</a> </div> <div class=""> <br class=""> </div> <div class=""> As you’ll see, I have two submissions, one for the added persons, which is looping as long as there are new persons, and a second one for the main instance which is running when all the new persons have been submitted. </div> <div class=""> <br class=""> </div> <div class=""> I use the dispatch method, with the xforms-submit-done event, and a @delay : </div> <div class=""> <br class=""> </div> <div class=""> <div class="" style="margin: 0px; font-stretch: normal; line-height: normal; background-color: #3c3c3c;"> <span class="" style="color: #5fc8fd;"><xf:action</span><span class="" style="color: #ff8d54;"> ev:event</span><span class="" style="color: #ff8040;">=</span><span class="" style="color: #e06a53;">"xforms-submit-done"</span><span class="" style="color: #5fc8fd;">></span><span class="" style="color: #000000;"><br class=""></span><span class="" style="color: #e5e5e5;"><span class="" style="caret-color: #e5e5e5;"> </span></span><span class="" style="color: #5fc8fd;"><xf:dispatch</span><span class="" style="color: #ff8d54;"> name</span><span class="" style="color: #ff8040;">=</span><span class="" style="color: #e06a53;">"submission"</span><span class="" style="color: #ff8d54;"> targetid</span><span class="" style="color: #ff8040;">=</span><span class="" style="color: #e06a53;">"model"</span><span class="" style="color: #ff8d54;"> delay</span><span class="" style="color: #ff8040;">=</span><span class="" style="color: #e06a53;">"1"</span><span class="" style="color: #5fc8fd;">/></span><span class="" style="color: #000000;"><br class=""></span><span class="" style="color: #5fc8fd;"></xf:action></span> </div> </div> <div class=""> <span class="" style="color: #5fc8fd;"><br class=""></span> </div> <div class=""> Then I have a "if" rule to select the submission to run : </div> <div class=""> <br class=""> </div> <div class=""> <div class="" style="margin: 0px; font-stretch: normal; line-height: normal; color: #e06a53; background-color: #3c3c3c;"> <span class="" style="color: #5fc8fd;"><xf:action</span><span class="" style="color: #ff8d54;"> ev:event</span><span class="" style="color: #ff8040;">=</span>"submission"<span class="" style="color: #5fc8fd;">></span><span class="" style="color: #000000;"><br class=""></span><span class="" style="color: #e5e5e5;"> </span><span class="" style="color: #5fc8fd;"><xf:send</span><span class="" style="color: #ff8d54;"> if</span><span class="" style="color: #ff8040;">=</span>"instance('sub')/xpr:person[@localType='new']"<span class="" style="color: #ff8d54;"> submission</span><span class="" style="color: #ff8040;">=</span>"submitNewPerson"<span class="" style="color: #5fc8fd;">/></span><span class="" style="color: #000000;"><br class=""></span><span class="" style="color: #e5e5e5;"> </span><span class="" style="color: #5fc8fd;"><xf:send</span><span class="" style="color: #ff8d54;"> if</span><span class="" style="color: #ff8040;">=</span>"not(instance('sub')/xpr:person[@localType='new'])"<span class="" style="color: #ff8d54;"> submission</span><span class="" style="color: #ff8040;">=</span>"submitBio"<span class="" style="color: #5fc8fd;">/></span><span class="" style="color: #000000;"><br class=""></span><span class="" style="color: #e5e5e5;"> </span><span class="" style="color: #5fc8fd;"></xf:action></span> </div> </div> <div class=""> <span class="" style="color: #5fc8fd;"><br class=""></span> </div> <div class=""> Like Steven suggests, I think now that there is a submission activated twice, as the submission#submitBio is running two time and it shouldn’t, but maybe I’m doing something wrong ? </div> <div class=""> <br class=""> </div> <div class=""> Thanks a lot for your help, </div> <div class=""> Best, </div> <div class=""> Josselin. </div> <div class=""> <br class=""> <div> <br class=""> <blockquote type="cite"> <div class=""> Le 5 févr. 2021 à 10:54, Steven Pemberton <<a class="" href="mailto:ste...@cw...">ste...@cw...</a>> a écrit : </div> <div class=""> <div class=""> Although submissions are by default asynchronous, a submission element may only be activated once at a time. I'm surprised that all the event values are empty; they really shouldn't be for an xforms-submit-error event. <div class=""> <br class=""> </div> <div class=""> There is a difference in semantics between a dispatch with and without a delay, even if the delay is 0, so try making the delay 0, it should still work. The fact that it works with my original dispatch method suggests that the problem is indeed with a submission being activated twice, but my reading of the spec is that it should be possible once submit-done has been dispatched. I will raise this with the working group. </div> <div class=""> <br class=""> </div> <div class=""> Best wishes, </div> <div class=""> <br class=""> </div> <div class=""> Steven <br class=""> <br class="">On Thursday 04 February 2021 23:42:37 (+01:00), Josselin Morvan wrote: <br class=""> <br class=""> <blockquote> Hi Steven, <div class=""> <br class=""> </div> <div class=""> Thank you for your quick response. Unfortunately, all the error events are empty. </div> <div class=""> So, I tried your method with the dispatch element. At first it didn’t work either, then I added a delay to the dispatch and… it works! </div> <div class=""> <div class=""> As I said, when the submission is done, I update my instance with the server’s response (@xml:id and @localType value, etc.) and then I perform the next submission, maybe all these actions are asynchronous or performed simultaneously, and it produces a conflict? The @delay would allow to really execute the next submission at the end of the entire process? </div> <div class=""> <br class=""> </div> <div class=""> Best, </div> <div class=""> Josselin. </div> <div class=""> <br class=""> <blockquote type="cite"> <div class=""> Le 4 févr. 2021 à 22:25, Steven Pemberton <<a class="" href="mailto:ste...@cw...">ste...@cw...</a>> a écrit : </div> <div class=""> <span class="" style="display: inline; float: none; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-decoration-line: none; -webkit-text-stroke-width: 0px; word-spacing: 0px; white-space: pre; text-transform: none; text-indent: 0px; text-align: start; letter-spacing: normal; font-weight: normal; font-variant-caps: normal; font-style: normal; font-size: inherit; font-family: monospace; color: #0000ff; caret-color: #0000ff;"><message>Submission error. error-type: <output value="event('error-type')"/> error-message: <output value="event('error-message')"/> response-status-code: <output value="event('response-status-code')"/> response-reason-phrase: <output value="event('response-reason-phrase')"/> resource-uri: <output value="event('resource-uri')"/> </message></span> </div> </blockquote> </div> <br class=""> </div> </blockquote> <br class="">-- <br class=""> </div> </div> </div> </blockquote> </div> <br class=""> </div> </div>_______________________________________________ Xsltforms-support mailing list Xsl...@li... https://lists.sourceforge.net/lists/listinfo/xsltforms-support </blockquote> </body> </html> |