[Xsltforms-support] refreshing the screen while performing a submission - why does this not work?
Brought to you by:
alain-couthures
From: C. M. Sperberg-M. <cm...@bl...> - 2016-06-20 18:32:36
|
I have a form that performs a query against a database back end, shows the results, and keeps the search box open so the user can issue a new search. http://tlrr.blackmesatech.com/2016/01/balbus.xhtml (Useful searches: "Alfenus", "Balbus" for fast searches, "Cicero" for a slower one.) In the current version of the form, nothing visual happens when the user issues a new search; if the search is slow, the user can think "something went wrong, the browser didn't notice the click, I'll click again". So I'd like the Search button to clear the old results, display the text "Query in progress ..." in some way (ideally in the work area where the results used to be), and issue the query submission to the back end. A first cut made the trigger look like this: <xf:trigger> <xf:label>Search</xf:label> <xf:action ev:event="DOMActivate"> <xf:delete nodeset="instance('results')/child::node()"/> <xf:insert context="instance('results')" origin="instance('ui')/query-in-progress"/> <xf:setvalue ref="instance('q')/startpos" value="1"/> <xf:send submission="send-query"/> </xf:action> </xf:trigger> And I added the 'Query in progress ...' display this way: <xf:group ref="instance('results')/query-in-progress"> <p>Query in progress ...</p> </xf:group> (It should be noted that the send-query submission replaces the 'results' instance entirely, so the empty 'query-in-progress' element there goes away when the results of the query are returned.) The trigger and group just shown, however, do not in fact make the old results disappear or the text "Query in progress ..." appear; there no change to the display until the results of the query come back. Consulting the spec, I see that my problem is apparently described in the section on 'deferred updates', near the beginning of section 10: > Deferred Updates: Sequences of one or more XForms Actions have a deferred effect on XForms model and user interface processing. Implementations are free to use any strategy to accomplish deferred updates, but the end result must be as follows: Instance data changes performed by a set of actions do not result in immediate computation dependency rebuilding, recalculation, revalidate and form control refreshing until the termination of the outermost action handler, as described here. OK, I think I can see the point of that rule. Later on in the same section, however, it says > Actions that directly invoke rebuild, recalculate, revalidate, or refresh always have an immediate effect, and clear the corresponding deferred update flag. The XForms Actions in this category are: > > rebuild > recalculate > revalidate > refresh So I tried inserting first one, then a different one, and finally all four of these actions into my trigger: <xf:trigger> <xf:label>Search</xf:label> <xf:action ev:event="DOMActivate"> <!--* <xf:message level="ephemeral">Query in progress</xf:message> *--> <xf:delete nodeset="instance('results')/child::node()"/> <xf:insert context="instance('results')" origin="instance('ui')/query-in-progress"/> <xf:rebuild/> <xf:recalculate/> <xf:revalidate/> <xf:refresh/> <xf:setvalue ref="instance('q')/startpos" value="1"/> <xf:send submission="send-query"/> </xf:action> </xf:trigger> The result is that the behavior is still unchanged. Have I misunderstood the spec? Am I doing something wrong? How can I cause a single button press to (a) clear the results and display a 'be patient' message, and (b) perform a submission which will automatically clear that be-patient message when the results come back? Thanks for any help. -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net **************************************************************** |