Thymeleaf editing th:field before action

Viewed 19

I have a simple pagination that looks like

<ul class="pagination justify-content-end" th:field="*{page}">                
    <li class="page-item page-item disabled">
        <a class="page-link" href="action">1</a>
     </li>          
</ul>  

I would get the following behaviour with Thymeleaf. Clicking on the page and before submitting the action, the value of the th:field associated with the pagination should be changed by setting it to the th:value of the selected page. In other words, clicking on the page number should change the value of "*{page}" and then call the method. Is there any way to do that, for example, combining th:onclick with th:action?

1 Answers

Thymeleaf is a rendering engine, as such it can do nothing once the page is served to the end user. At best u can fill variables into javascript when rendering to achieve the desired result.

As for your described functionality the given code is far to limited or faulty to give a suggestion for a javascript solution, for one th:field on a non-input element doesn't do much. Also the shown href is just a simple href that doesnt interact in any way with the encapsulating th:field.

Related