"Reuse" of standard/spring features in own dialect

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"Reuse" of standard/spring features in own dialect

Klaus Unger
Hello,

we are in the early stage of the implementation of a rather large Spring Boot + Thymeleaf web application.

For architectural reasons, we aim to abstract common markup patterns (like label + formfield + error-message) with an custom dialect.

Currently we are facing problems in reusing existing attributes like th:if="#fields.hasError(...)" or th:errors(...).

We want to write something like:

<mydialect:form-input-text label="#{lbl.label}" id="fbNr" field="*{fbNr}" />

instead of:

<label for="fbNr" class="..."><strong th:text="#{lbl.label}"/>
<input type="text" class="..." id="fbNr"  th:field="*{fbNr}"/>


We are able to produce the required markup by implementing our own AbstractMarkupSubstitutionElementProcessor, but we do get RT errors because we didn't find a way
to invoke fields.hasErrors and th:errors programmatically.

Any hints are highly appreciated!

Thanks & kind regards
K:) Unger

Reply | Threaded
Open this post in threaded view
|

Re: "Reuse" of standard/spring features in own dialect

Zemi
Administrator
Hello Klaus,

making everything work in generated markup is a bit tricky (but possible).

May I suggest thinking on using fragments instead of a custom dialect? I think it suits better your needs.

Regards,
  Zemi