Open THD-Thomas-Lang opened 4 years ago
Moving to the thymeleaf-spring repo as I suspect the issue is closer to the Spring side than just Thymeleaf - a search for "Neither BindingResult nor plain target object" results in lots of posts about Spring MVC, regardless of templating technology used.
I don't think this is a bug neither in Thymeleaf nor Spring.
When you return a fragment that doesn't have a th:object, the *{}
notation can't be used.
I use a model container
Invoice
with a givenname
and a list of givenInvoiceItems
to be rendered to html with thymleaf. I am binding the model toth:field
within my form. Everything works fine.No i want to add
InvoiceItems
to theInvoice
container dynamically without refreshing the whole page (because in the real world my invoice object is very rich (beside this items)):InvoiceItem
to the list of thoseAfter that i get this exception: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'items[0]' available as request attribute
When i debug the application i can see the right model values and even the right amount of items.
Please note I: I have the same issue with JSP, so maybe this is a spring issue. But maybe you can help me with that though.
Please note II: My workaround for this issue is to use a dedicated view for that. It is basically the same view as originally but with the model´s name prefixed to the th:fields. Strange, but it works.
I have already done a stackoverflow question - but without success: https://stackoverflow.com/questions/41242507/spring-modelattribute-not-recognized-anymore-after-ajax-update
Repository to comprehend this issue https://mygit.th-deg.de/tlang/thymefail