Monthly Archive: August 2016

Spring Boot / Thymeleaf: Fragments via Ajax

This is probably not the best approach and you guys can feel free to correct me in the comments section, but here is a simple tutorial on how I’m getting my fragments loaded via ajax. Same as before, the full project is on my Github: https://github.com/mtrojahn/spring-thymeleaf-fragments-from-ajax Let’s get to it: MyController.groovy

Very simple controller. Nothing special except for the fact it’s returning Thymeleaf fragmets from /resources/templates/fragments. As you probably noticed, for the sake of this example, each fragment is recieving it’s “content” from the controller. Here’s a fragment: frag1.html

Now the index.html

Each button has it’s event and is calling...

Spring-Boot / Websocket Example

It’s been a while! Project for this post: https://github.com/mtrojahn/spring-boot-websocket Recently I stumbled upon the need of using Websockets. I confess I know little about the subject and I hope this little tutorial can help you to get started. I’m making this post just because I tried to help here on StackOverflow and I thought I should just post it here as well. pom.xml

Application.class (nothing special here)

WebSocketConfiguration.class

PingPongController.class

This is the main thing. For this example I added a scheduled method that will periodically broadcast a message to all clients and another method that will just...

%d bloggers like this: