0

this is my first project using spring webflow and thymeleaf. It is also my first web project, so please be nice.

This is the situation: I have a list of items and an associated button to each of them in a view-state. I can add items by just putting them at the end of the list, but I don’t know how can I do to delete an item? The question is how can I “send” the id of my item through a webflow event?

I have seen other related post, but I can’t get how to implement the solution using thymeleaf I really appreciate any help you can provide.

Here is my code

My flow:

<view-state id="myDatabases">

    (Other transitions...)

    <transition on="deleteDatabase">
        <evaluate expression = "experimentService.deleteDatabase(requestParameters.dbId)"/>
    </transition>

</view-state>

My view:

(...)

<tbody>
    <tr th:each="databaseIterator : ${databaseList}" th:object="${databaseIterator}">
    <td th:text="*{name}">Database name</td>
    <td th:text="*{obtainDataSourceDescription()}">DSource Names</td>

    <td>                
        <form action="#" th:action="${flowExecutionUrl}" method="post">
            <button type="submit" id="deleteDatabase" name="_eventId_deleteDatabase">Delete</button>
        </form>  
    </td>

        </tr>

</tbody>

(...)
Community
  • 1
  • 1
MYed
  • 1
  • 2

1 Answers1

0

in this case, all you need is to add a hidden input with requestParam name and set its value to the current row's id. like this :

<input type="hidden" id="dbId" name="dbId" th:value="${databaseIterator.id}"/>
Hossein
  • 1,151
  • 9
  • 19