Skip to Content

How to save dynamically created elements. SAPUI5

Hello,

I`m stuck on data saving.(Web IDE/SAPUI5).

I have to create a Survey app and it need to works like Google Forms(Survey). At the moment, i can create new questions and they are saving in my HDI-container. But i need form with dynamically created questions, they could be with radiobuttons or checkboxes, and here is the problem, i don`t know how to save it and display after. I could save it like simple text and after split it for dynamic element creation, but i think it incorrect.

My idea:

question: "How are you?|radiobuttons|Fine;Bad;So-so;&How old are you?|radiobuttons|<18;18<;"
So here is two questions with radiobuttons.

I hope you realize what i mean.

Thank you a lot,

Dmitry

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Apr 12 at 08:03 AM

    Hi Dmitry,

    If I understood you correctly, you could use databinding and aggregations to show the element you want to display.

    I created a minimalic version here:

    https://jsfiddle.net/u713f2tz/

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Dmitry Bez,

      you need to build this via question and answer relationship. Question is one entity and Answers is another entity. So when user clicks on add button, just create an entry in question entity, then for every answer, create an entry in answers (with proper key mappings between question and answer). Then on save, submit all the data in the form of deep or batch to the backend. Then while reading it, you will read the data and show the UI.

      Now following the Marius approach, This Questions entity is bound to one VBOX and inside that another VBOX with answers entity, so by this you will show the UI (both for create and read) This better be done using the JSON Model for read and update locally. For saving to DB use ur XS OData or ABAP OData. (UI you don't neccessarly need to use the VBOX approach, but the idea is to use the aggregation concept)


      BR,

      Mahesh