Skip to main content

Posts

Showing posts from 2019

The audiobooks I've been listening to

Last week I've written about my personal updates and I mentioned that nowadays I'm listening to audiobooks while I'm commuting to and from work. I'd like so share about some of my experience listening to the audiobooks and some titles I've personally enjoyed a lot. I use audible to listen to audiobooks. Listening to audiobooks is of course very different than actually reading a book. The main difference being that you can't read at your own pace, it would be at the pace of the narrator. And your enjoyment of the content is also very much dependent on the narrator almost as much as on the author. A great book can become quite boring if the narrator just keep on droning flatly through. And a boring book can be become great when the narrator can read it so enthusiastically that it become infectious. So in some ways, buying an audiobook is a bit more riskier than buying a book. Another difference is that with books, you can very easily skim through again to find so…

Personal Update

I haven't written a lot lately. It's mostly because I haven't got a lot to say that was important enough for me to spend time and write it out. I think that's probably a mistake. I should probably write more just to practice writing and to be more articulate. So I'm trying out a new schedule where I try to write something out at least once a week. I'm going to think of something to write every week and use the whole week to write bits and pieces of it until I can get round to putting it all together to be published on Wednesday. And since this is the first time I'm doing this and I haven't prepared anything for this week, I figure I'll just try something easy like sharing my own personal updates this year. So it's almost the end of 2019. It has been quite a roller coaster ride for me. Just last year, the Pakatan Harapan formed a new government after the 14th General Election in 2018. Ever since then, well.. life has been pretty much the same. T…

Rendering template from string using thymeleaf in spring

Finally solved a very big problem for me... How do I render a page in spring framework that uses the thymeleaf templating engine? The string most probably will come from the database. After long hours of searching and trying, I've got it.

First I've got a clue from this particular stackoverflow question. But following an example from there got me an error about class not found for ognl.PropertyAccessor. That solution was found here.

So here's how I finally done it...

First thing is to create a service where that service can be used wherever you need it in your spring app.


@Service public class PortalService { private TemplateEngine templateEngine; private final static String TEMPLATE_LOCAL = "US"; private TemplateEngine getTemplateEngine(){ if(null == templateEngine){ templateEngine = new TemplateEngine(); StringTemplateResolver templateResolver = new StringTemplateResolver(); templateResolver.s…