cancel
Showing results for 
Search instead for 
Did you mean: 

How to save dynamically created elements. SAPUI5

former_member603527
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

mariusobert
Developer Advocate
Developer Advocate

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/

former_member603527
Participant
0 Kudos

Hi Marius,

Thank you a lot!

What you think about this :

<root>

<surveys>

<survey>

<survey-title text="Simple Questions"/>

<Questions>

<question>

<title>How are you?</title>

<answers>

<answer type="radio">Fine</answer>

<answer type="radio">So-so</answer>

<answer type="radio-input" placeholder="Enter your answer"/>

</answers>

</question>

<question>

<title>What you prefer?</title>

<answers>

<answer type="check">Banana</answer>

<answer type="check">Orange</answer>

<answer type="check">Lemon</answer>

</answers>

</question>

</Questions>

</survey>

</surveys>

</root>

How you think, possible dynamically create this xml and read/update it?

Best regards,

Dmitry

maheshpalavalli
Active Contributor

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

Answers (0)