Getting Liferay JournalArticle localized content in Java

I thought my adventures in Liferay would end at a hook and CKEditor, however I had to do some display of JournalArticles. And again, this was not an easy thing.

But I have found a solution. To get a Liferay JournalArticle’s content as XML, you can call

article.getContentByLocale("en-US");

However this returns you the content in XML — and this is a bit hard to display. The suggested solution is to use JournalContentUtil provided by Liferay. It has a method getContent where you set the right variables you get your content — and only the content.

String content = JournalContentUtil.getContent(groupId, articleId, templateId, themeDisplay.getLocale().toString(), themeDisplay);

I won’t go into detail which parameters to set and how to get them. There are some questions around on the internet (at the Liferay Forum too) where you can take a look at and get some information.

However this is not working as you might expect. If you have content in only one language: go along and use the suggested method (and look for information on the internet).

If you have translations in other languages, then it is not working. You can add a language attribute but it does not help either: you get the content in the main language back (or the language of the user logged in) — and it is a problem if you want to display the contents in another language.

Continue reading

What do I do currently?

This article is about what am I doing currently and what my plans are for this blog in the (near) future.
I’d say it is worth to read this article although it does not contain any code or examples. However it contains topics for future articles and code examples…

Continue reading

Projects with Databases

As I introduced my favorite projects for programming language learning, it came across my mind to make some more complicated applications too where database usage could be a key element. That is because nowadays most applications need a database behind them to store data — or just collect data from a database filled by another application.

In this article I’ll introduce some projects where databases should be used.

Continue reading

Use Case for UserTransactions in Java EE 6

There are some constructs in CDI which are available to injection per default but you do not see right out-of-the-box for what use case it can be good. Or if you have a use case you do not know how to use this bean.

I had the same problem with UserTransaction and now I share my knowledge about the topic.

Continue reading

Craft Conf 2015 – with 10% discount

If someone is interested: I am going to the CraftConf 2015.

It will take place in Budapest, between the 22nd and 24th of April. The first day is a workshop day, the other two are the days of the conference.

It seems to me that this will be a great event to extend knowledge and exchange experience with fellow developers. Why won’t you join in?

And beside the conference you can stay over the weekend to do some sightseeing in Budapest. Nice capital city, has a lot of sights — and has good and cheap bars (I’ve lived there three years long so I know 😉 ).

And I have a promotional code with you can get 10% off of the price.

So if you are interested, just mail me or write a comment with your email address and I’ll send you the code as soon as I read your message.

And hurry: there are only 42 tickets left…

Wizpert — a real-time StackOverflow with other extensions

If you have a problem with programming, you’ll find answers if you search on the internet on StackOverflow. If you do not find the answers, you ask your question and hope that someone answers.

A new platform, Wizpert offers you to chat with on-line experts about your problems.

Continue reading