Display a table by clicking on a form button


#1

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!!


#2

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


#3

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.


#4

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


#5

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!


#6

@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


#7

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?


#8

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