Thymeleaf - Tiles 2 integration module - Java Config

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

Thymeleaf - Tiles 2 integration module - Java Config

Eric Francis
Is this the correct way to register the template module?

@Bean
        public SpringTemplateEngine templateEngine() {
                SpringTemplateEngine templateEngine = new SpringTemplateEngine();
                templateEngine.setTemplateResolver(templateResolver());
                Set<IDialect> dialects = null;
                dialects.add(tilesDialect());
                templateEngine.setAdditionalDialects(dialects);
                return templateEngine;
        }

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf - Tiles 2 integration module - Java Config

Zemi
Administrator
This is a bit strange

                Set<IDialect> dialects = null;
                dialects.add(tilesDialect());

Doesn't it raise a NullPointerException?

Better
                Set<IDialect> dialects = new HashSet<IDialect>();
                dialects.add(tilesDialect());
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf - Tiles 2 integration module - Java Config

Eric Francis
Yes it does raise a null pointer.
Why is that?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf - Tiles 2 integration module - Java Config

Zemi
Administrator
In the second line you're trying to invoke method add() in a null object:

                Set<IDialect> dialects = null;
                dialects.add(tilesDialect());

You have to initialize dialects variable in order to be non-null.
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf - Tiles 2 integration module - Java Config

Eric Francis
I understand. Thank you very much.