Display a table by clicking on a form button

Hello,

I want to display a table which needs to be filled with a variable containing a response of a REST service. I need this to be shown after clicking on a form button. Any guidance on how can I achieve this?

Thank you!!

Hi Romina,

what kind of Form are you currently using?

I suggest you take a look at embedded forms if you havenā€™t already.

Best Regards
Martin

1 Like

Iā€™m using embedded forms. I define it on an html file. I want the user to fill certain fields and after clicking a button, I want to display a table.

In this table I want to fill it cells based on a response which i want to obtain after clicking that button.

Now, i realize i have a major question. Can I define that after clicking that button, certain function is executed? From this execution (which is a REST service) is from where I will obtain the info to fill the table cells.

Yes, this is possible. You can execute custom JavaScript in embedded forms. See the example here: https://github.com/camunda/camunda-bpm-examples/blob/master/usertask/task-form-embedded/src/main/webapp/start-form.html#L72-L106

But without executing custom JavaScript in my embedded form, can I associate the button to some class and in that class call the REST service and with the response fill the table on my form?

Thank you!

@Romina_S

What kind of class are we talking about? It is not possible to attach a Java Class to a Form field.

To me, custom JavaScript seems like the obvious solution. Simply add an ā€˜onclickā€™ event to the button and make a REST call. Please explain in more detail what you are trying to achieve and why you canā€™t use JavaScript

I thought the best way was to use a controller but i was not having any success :pensive:
So, I should include a custom JavaScript on my form? And on the ā€œonclickā€ event I put a function of my script?

Yes, simply add a script tag in you html and add the function you define inside to your buttons onclick event