RESTXQ design pattern question
Thursday, 6 January 2022 · 2 messages · last reply 7 Jan 2022
HR
Hans-Juergen Rennau6 Jan 2022 16:26 #
Hello,
I have a question concerning RESTXQ design patterns.
Imagine you have a page P1 displaying an input field, and you want to provide a button enabling the user to pick the terms from a list, rather than entering them. So after pressing the button, another page P2 appears, listing the terms and enabling a selection.
After selection, P1 should again appear, looking as before, except for the selected terms appearing in the field. A common pattern, isn't it. How to implement it? One approach would be P2 calling P1 (via form/@action), passing the selection to P1 as form or query parameters. But then the input of P1 must include everything required to restore the previous appearance, including the values of input fields from forms not yet submitted. There is certainly a simpler way? I suppose a standard approach handles this completely with JavaScript, updating the page. I wonder if RESTXQ and supporting modules enable some alternative? Thank you, with kind regards -Hans-Jürgen
CG
Christian Grün7 Jan 2022 18:29 #
…hardly possible to give a concise and distinct answer on this. If you use basic JavaScript without any frameworks (Angular, React, VueJS, etc.), you may need to pass on all data to the server via the POST request (triggered by your input form) and generate a server-side answer which includes the chosen values.
Once again, the DBA code includes various examples for that. See e.g. [1] for the user form, which contains a select element list with the permissions.
[1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/users/user.xqm
Quoted text · Hans-Juergen Rennau · 18 lines
On Thu, Jan 6, 2022 at 4:28 PM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > Hello, > > I have a question concerning RESTXQ design patterns. > > Imagine you have a page P1 displaying an input field, and you want to provide a button enabling the user to pick the terms from a list, rather than entering them. > > So after pressing the button, another page P2 appears, listing the terms and enabling a selection. > > After selection, P1 should again appear, looking as before, except for the selected terms appearing in the field. > > A common pattern, isn't it. How to implement it? One approach would be P2 calling P1 (via form/@action), passing the selection to P1 as form or query parameters. But then the input of P1 must include everything required to restore the previous appearance, including the values of input fields from forms not yet submitted. > > There is certainly a simpler way? I suppose a standard approach handles this completely with JavaScript, updating the page. I wonder if RESTXQ and supporting modules enable some alternative? > > Thank you, with kind regards - > Hans-Jürgen
Written for BaseX 9.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery