Custom dialect missing attributes
See original GitHub issueHi, I am creating a custom tags using thymeleaf 3. Initially it is created in thymeleaf 2, but since we are upgrading to versioin 3 we need to rewrite our current custom tags.
We had some issue related to th:field attributes (and other th:* commands). Upon accessing the custom element itself the supposed generated name and value field from th:field is not there or even a th:field itself. Our custom tag has higher precedence than the th:* tags as we would like to retrieve the generated value. Below is from our logs:
HTML
<extra:file th:document="${document}" th:field="*{regFile}" class="form-control" th:text="${docId}"></extra:file>
LOGS
_This part is retrieved from the ITemplateContext.getElementStack -_
FileTagProcessor.doProcess:101 - getElementCompleteName---------------------------->extra:file
FileTagProcessor.doProcess:106 - getAttributeMap: {th:document=${document}, th:field=*{regFile}, class=form-control, th:text=${docId}}
_This is retrieved from IProcessableElementTag_
FileTagProcessor.doProcess:109 - getAttributeMap: {document={"docTypeId":180,"docDesc":{"en":"Upload File"},"order":1,"type":"image/gif, image/jpeg, image/png, application/pdf","size":1000000,"compulsary":true,"dimensionCompulsary":false}, class=form-control} - {}
FileTagProcessor.doProcess:112 - IAttribute---------------------------->document="{"docTypeId":180,"docDesc":{"en":"Upload File"},"order":1,"type":"image/gif, image/jpeg, image/png, application/pdf","size":1000000,"compulsary":true,"dimensionCompulsary":false}"
FileTagProcessor.doProcess:112 - IAttribute---------------------------->class="form-control"
FileTagProcessor.doProcess:116 - label: {"docTypeId":180,"docDesc":{"en":"Upload File"},"order":1,"type":"image/gif, image/jpeg, image/png, application/pdf","size":1000000,"compulsary":true,"dimensionCompulsary":false}
FileTagProcessor.doProcess:120 - label: 180
Extra Dialect precedence is 100000 File Tag precedence is 2147483647
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Thymeleaf custom dialect with fragments: how to keep th
I'm creating a custom dialect that replaces <myprefix:mytag> with a <div th:replace="myTagFragment::myfrag"> and it works with no attributes or ...
Read more >Creating Custom Hibernate Dialect - DEV Community
So let's see, how to create our own Hibernate dialect to be able to use similarity function in HQL or Criteria Queries.
Read more >How to Extend Thymeleaf with dialects - Educative.io
The process is simple: create a dialect; add it to the template engine; we'll be able to make use of it. ... true,...
Read more >Tutorial: Extending Thymeleaf
Solution: create a Thymeleaf dialect with the tags or attributes you ... of the th:object attribute, but custom processors can do it too....
Read more >[RFC] mlir::FloatAttr and legal types - LLVM Discourse
These MLIR types are closed and incapable of representing dialect Foo's constants, attributes, or types. Since the goal is to lower the Foo...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, yes having a higher precedence than the standard dialect will mean you miss out on seeing things like
th:field
in its raw state 🤔Some workarounds that I can think of:
th:field
value<form>
, and then search through all of its input elements to find theth:field
attributes you want to work withSo
th:field
will do that, but it’ll have to be on an HTML input element that it knows about, not a custom one like<extra:file>
.Given this, one option to try is to change from using a custom element to a custom attribute, use an HTML input element so that
th:field
can add the id and name as it normally would, then your attribute processor can read those values from the element after, eg:(I can’t remember if you can have custom attributes without values. If not, then making it
extra:file=""
should fix that up.)th:field
will recognize<input type="file">
and add the appropriateid
andname
attributes, then yourextra:file
attribute processor can read them from the input element.