Simple REST App in Web Content Management (JSONFactoryUtil and HttpUtil)

Technical Blogs August 21, 2014 By Scott Lee Staff

I've heard that you can do some really cool stuff in Web Content (check out James's and Ray's blogs) but haven't gotten around to tinkering with that myself.  Here is a fun little experiment with that, it grabs a Chuck Norris joke from a REST API, all from inside of a Web Content template.



And here is the code for the Web Content Template:

#set($jsonResponse = $jsonFactoryUtil.createJSONObject($httpUtil.URLtoString('')))

<p>We are calling a <a href="">simple REST API which grabs a Chuck Norris joke</a> and displaying part of our web content based on that response.</p>

<p>Output some values for debuging purposes:</p>

    <li>jsonFactory: $jsonFactoryUtil (This will display the full package name if this loads correctly)
    <li>Response: $jsonResponse

#if ($jsonResponse.getString('type') == 'success')
    <div class="portlet-msg-success">
    <div class="portlet-msg-error">
        You broke the interwebs.


Additional Notes:

  • You can paste this into any web content template.  This outputs the same thing regardless of what is in your structure and web content.
  • Tested against 6.1.30 and 6.2.10
  • Uncheck "cacheable" if you want to load a new joke each time the page refreshes.
  • When using this code snippet, make sure that you have the script language set to "Velocity".
  • For this example, you wont need to enable restricted values from velocity or freemarker, but if you need more power and want to use Liferay services, be sure to check that out.

Mail Portlet.. some screenshots : )

Company Blogs September 5, 2008 By Scott Lee Staff

Here are some screenshots for the new mail portlet.  You can check out jerry's post on how to install the mail portlet. It is as simple as clicking around in the plugins installer.  The mail portlet that I am using is running on the latest 5.1.x branch so you may notice some slight ui changes in the portal, but the mail portlet is the same.

Splash Screen:


For now, the initial screen is very simple.  It gives you the options to either check your mail or configure your email accounts.


Account Configuration Screen:


This is the configuration window.  You can customize pre-configured accounts.  You can add and remove whatever accounts you want.  If you want to add remove the pre-configured Gmail account, add others and modify whatever from the file inside the portlet.

Note: after you add your account, you may have to wait a few minutes before your first page of emails is retrieved.  Some technical details behind the process is.. It will grab a list of the folders, then grab the first page of each folder, then go back for the second page of each folder.. etc. 


 Viewing your mail folders:

Notice at the top left, there is a drop down list.  That list contains all your configured mail accounts.  You can switch between accounts by selecting a different account from the list.


Reading a message:

You can view your email in plaintext or html, whichever is provided by the sender.


Note: This email is an add from alienware (and windows vista).  im not a fan of either.. and i dont own any alienware stuff and neither do i run vista.. but the email looked cool.. so im using it for the screenshot : )  In case you are curious.. at Liferay we have all kinds of machines going.. apple, dell, hp.. no alienware : )  at least not that i know of.


Replying to a message:

When replying to a message, you are provided with a full wysiwig editor.  The editor used in this screenshot is "tinymcesimple" which can be configured from  The mail portlet will currently use the default editor from the properties file.


Hope that gets you to want to give the mail portlet a try.  suggestions, code fixes and improvements are totally welcome : )


LDAP improvements.. things to come in Liferay Portal 4.4

Company Blogs December 17, 2007 By Scott Lee Staff

So ive been tweaking with the LDAP stuff recently to make it easier for people to do LDAP integration in Liferay.  We've added some default LDAP server settings (feel free to send me corrections or additions.. i know there are many more LDAP servers out there) and also tweaked the code a bit to allow live "Test" buttons for the LDAP connection, user mapping and group mapping.  here's a preview:


LDAP Settings


Test Connection "Success"


Test Connection "Fail"


Test Connection "User Mapping"


Test Connection "Group Mapping"


For more information about LDAP Integration in Liferay see wiki article: LDAP

Showing 3 results.