java - Spring and Thymeleaf: Sending an object to a controller from a th:each table -


i making table of experience data using th:each attribute thymeleaf , goal have submit button in each row that, when clicked, send experience object controller corresponds row clicked submit button in.

i have no idea whats wrong , can't seem find online problem.

here section of webpage code:

<div th:unless="${#lists.isempty(borrower.experiences)}">     <h2>list of experiences</h2>     <!--  <form action="#" th:action="@{/initiate-edit}" th:object="${experience}"       method="post">-->         <table id="your-table-id">           <thead>             <tr>               <td>edit buttons</td>                 <th>date planted</th>                 <th>rating</th>                 <th>category</th>                 <th>dept</th>                 <th>resolution</th>                 <th>source</th>                 <th>last update date</th>                 <th>last update name</th>                 <th>comment</th>             </tr>           </thead>           <tbody>               <tr th:each="experience : ${borrower.experiences}">                        <td>                   <form action="#" th:action="@{/initiate-edit}"                      th:object="${experience}" method="post">                     <!--<a th:href="@{/initiate-edit/}">click</a>-->                     <button type="submit">submit</button>                   </form>                 </td>                 <td th:text="${experience.experiencedate}">13/01/2014</td>                 <td th:text="${experience.rating}">4</td>                 <td th:text="${experience.categoryshortdesc}">account , billing</td>                 <td th:text="${experience.deptdesc}">account , billing</td>                 <td th:text="${experience.resolutionshorttx}">account , billing</td>                 <td th:text="${experience.source}">account , billing</td>                 <td th:text="${experience.lastupdatedate}">account , billing</td>                 <td th:text="${experience.lastupdatedname}">account , billing</td>                 <td th:text="${experience.commentsshort}">account , billing</td>                   </tr>                          </tbody>        </table>     </div> 

here method sending to:

@requestmapping(value = "/initiate-edit", method = requestmethod.post)     public string initiateedit(@authenticationprincipal final user user,                                 @modelattribute("springweb")customerexperience editableexperience, final model model) {          log.info("this test!!!" + editableexperience.getssn());          model.addattribute("editableexperience", editableexperience);          return edit_page;      } 

you need fill form inputs inputs sent:

<form action="#" th:action="@{/initiate-edit}" th:object="${experience}" method="post">      <input type="hidden" th:field="*{experiencedate}"/>      <input type="hidden" th:field="*{rating}"/>      <!-- add other fields part of object -->      <button type="submit">submit</button> </form> 

this hide object data user when click on submit, send object data required (rather having empty form sent have currently).


Comments

Popular posts from this blog

python - How to create jsonb index using GIN on SQLAlchemy? -

PHP DOM loadHTML() method unusual warning -

c# - TransactionScope not rolling back although no complete() is called -