6/23/2011

Liferay 6.1 Features, Part 1 : The App - Store

Overview | Liferay App-Store | Required Categories | Page Customizations | Dynamic Data Lists


So, welcome to a set of posts about the forthcoming Liferay 6.1. Today we will take a look at the Liferay App Store, which is targeted for the release of Liferay 6.1 in Q4 2011.


The source for my post is (again) a Liferay presentation. You can download it here: Click


So, what is the Liferay App Store, how does it work? The App Store works as every other App Store does: Developers  have the possibility to program and submit Apps. They pay a part of their revenue to Liferay and therefore Liferay provides a portal that makes downloading and installing the apps very easy. Liferay also checks the apps for compatibility.


Apps


Apps can be developed in two flavours:


Free Apps


If you want to create and distribute free apps (wouldn´t a liferay-blogging app be just great?),all you have to do is to download the App SDK, read the Marketplace Developers Guide and create a Marketplace Profile. That´s all.


Selling Apps


If you want to sell apps (who doesn´t)  you need to buy at least a One - Year subscription to the Liferay Developer Program which costs 99$. By doing so you will get the right to sell your app- 20% of your revenues will go to Liferay. 
If you choose to sell your app, it will be validated by Liferays engineering team for compatibility with an EE release. CE validation is up to you. 


What you don´t get is the EE source code,what may be a little tricky when you want to publish hooks that (for example) extend the Asset Publisher. If you just want to sell portlets, then there will be no additional costs.


App Store


The Liferay App - Store will have all those features that you would expect when you think of iTunes or the Android Marketplace: Ratings, One-Click Buy Following and Smart Suggestions to let you buy even more apps :)




What is an app ?


An app is a typical liferay distributable: a portlet, webs, hooks, themes etc. - everything you can develop with the Liferay IDE is something you might sell. Isn´t that great ?? I can´t wait to get started ...


The Marketplace APIs gives you additional possibilities like In-App-Purchases.


When does it start?


According to the Liferay presentation, Early Q3 will be the time when you get the developer´s guide, Late Q3 allows you to take a sneak peak at the app store and the Launch is targeted for Q4.


If you like this post it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

6/18/2011

New Features of Liferay 6.1


Overview | Liferay App-Store | Required Categories | Page Customizations | Dynamic Data Lists


So - you are all using Liferay 6.06 CE or 6.011 EE and you want to know, what´s next ? Well, the folks at Liferay gave  a glimpse at what we can expect in Liferay 6.1. at the hungarian symposium. If you want to have the complete presentation, take a look at the slides held at 16:35PM:
http://www.liferay.com/de/events/liferay-symposiums/hungary-2011/agenda
If you just want to know what´s going on ... here are some of the new features:


1) Greatly Improved Document Library with a redesigned UI.

  • It allows to integrate several existing content repositories (CMIS, Sharepoint, Documentum, Alfresco). 
  • Image Gallery and Document Library will be unified

2) Support for Staging 

  • modify several versions of your portal at the same time 
  • create a special christmas version without having to change all your sites.

3) Web Content title and description will finally be translatable


4) Simplified publishing of contents

  • Let end-users publish content without having to fight with asset publisher properties.
  • Link Web Content Links to configurable pages

5) Taxonomy Enhacements 

  • internationalization for vocabularies and categories
  • mandatory vocabularies
  • multi valued categorization

6) Custom Entities


This seems to be very interesting: A possibility to create a Liferay Service with Entities and GUIs simply by using a portlet. Sounds like taking the Liferay Service approach to a whole new level by also generating GUIs and allowing Users to do this within Liferay - not within Eclipse. I am very curious how this fits in your development environment. How will the source code be stored ? How do we migrate from one server to another ? We´ll see.


7) Workflow Aware Forms


Very interesting approach to create workflows and the GUIs / Forms that fit into the workflow as single steps. Should be possible to define business processes without development. Lets hope that all this data is exportable somehow...


8) Implementation of OpenSocial 1.1 


Visit http://www.opensocial.org/


9) Improved Social Features


Liferay 6.1 will introduce a Contact Center that will contain all Friends, FriendsRequests, Followers etc. Very good feature that will incorporate all the portlets that you have to find for yourself, create a page, configure everything etc etc. It will also contain "short status updates"  - looks like a twitter clone to me. Let´s see how it works.


10) Redesigned Calendar portlet


Finally - the calendar portlet will be complete rewritten, looks a little like the Google Calendar.Possibility to add ressources like conference rooms and view the availability of these ressources. Great ! Maybe we can get rid of outlok and do it in Liferay. This will maybe help to save costs for firms.

11) Improved MessageBoards


12) Improved Blogs

  • Attachments
  • Autotagging
  • sharing via Facebook and twitter



13) Improved Chat


Weehow ! The Chat Portlet will be rewritten and will contain features such as message broadcasts to a group of users, offline messaging and a chat history with pruning

14) Mobile themes


Great - Mobile themes for iPhone, iPad and Android will be available out of the box. This is one of the main requested features of my customers.

15) Suport for SAML 2.0


Liferay will work as an SSO provider - nice. One of my customers has three consultants sitting and configuring the SSO Framework - costy !

16) Improved documentation


Ok, I am curious about that ...


17) Improved Liferay IDE and Liferay Developer Studio

  • Create JSF 2.0 Portlets
  • Visual UI builder with AlloyUI
  • Workflow designer

If you like this post it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

6/10/2011

How to change Portlet Preferences programmatically

If you are doing big liferay projects for huge firms you will know the problem, that you have to configure a lot of portlets. A once you did all the configuration, you have to do it again and again because links change, colors change, sizes of portlets change and so on. This post is a suggestion what you could do to get rid of most of this work.
Liferay stores the portlet preferences in an own table called "portletpreferences". This table is also accessible by a LocalServiceUtil and (of course) Dynamic Queries.

So - what you have to do is : Write a portlet that accesses this table and changes strings. Here is an example how these preferences may look. Imagine a portlet that is storing the information "test", "width", "height", "someValue" and "booleanValue":

portletPreferencesIdownerIdownerTypeplidportletIdpreferences
171310314110'your_portlet_id';portlet-preferences><preference><name>test</name><value>testvalue</value></preference><preference><name>width</name><value>65</value></preference><preference><name>height</name><value>2</value></preference><preference><name>someValue</name><value>walla</value></preference><preference><name>booleanValue</name><value>1</value></preference>'</portlet-preferences>

So, just iterate over all entries in the PortletPreferences table, check the portletId and change the preferenes column. This allows you to change a lot of portlet preferences with a simple click.

If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

6/09/2011

Categories in Liferay

If you want to add a category programmatically to some of your assets or you want to retrieve all objects that have been assigned a special category then you should read this blog entry. It helps you to filter out documents, tag Users or prevent communities from being discovered.


The basic knowledge you have to know is that liferay stores the information about "Which item has which category" in the following tables:


AssetCategory: Contains All Categories.
AssetEntries_AssetCategories: Contains the link between your objects (= asset entries) and the categories that have been assigned to them
AssetEntries: Asset Entries are special liferay representatives of every object you create in liferay. So for example Users, documents, pages etc etc.

If you want to retrieve all asset entries that have been assigned a certain cetagory, you will run into the problem, that you can´t access the table AssetEntries_AssetCategories by dynamic queries. But without dynamic queries you have to do a loooooot of retrieval work and manual filtering. I have pointed out a possible solution in this blog post : http://liferay-blogging.blogspot.com/2010/12/how-to-access-liferays-connection.html .



So, this is how you access the categories:


First, you need to know the entryId of the asset that belongs to your "liferay object". You can do this by using the standard classNameId / classPK way like you do it always in liferay. If you don´t know how to do it, leave me a comment.


Next, you get the categoryId from the AssetEntries_AssetCategories table, or you query your AssetEntry object with getCategories() which immediately returns all the categories you are interested in.


If you have the categoryId, you can access the table "AssetCategory".

If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

6/08/2011

jQuery, JSON and Liferay : One happy couple :)

From time to time you will have the requirement to load data asynchronously from a Liferay Service without having access to such nice technologies like ICEFaces or JSF in general. This post will show you how to use jQuery, JSON and AJAX to make such calls in a JSP portlet. Very, very useful !

Imagine the folllowing issue: Your customer tells you to implement two drop down lists: The first list contains all organizations in your Liferay environment, the second should contain the name of all users belonging to this organization. Your are not allowed to use JSF - just plain JSPs, enriched by AlloyUI, jQuery and JSON. Just a quick information before we begin: JSON is a very useful tool, that allows JAVA - Javascript conversion. This allows us to save a lot of time during development, because we don´t need to create converters. 

You could query the liferay database for all users, create tons of javascript objects and write some javascript methods that will remove and add elements to your SELECT boxes. This works for lilferay environments where there are very little users, but not for a standard enterprise environment. Here I would suggest doing the following:

We create a standard JSP page with two HTML SELECTs. The first one will be filled with all organizations that we find. When selecting an organization, a javascript method is triggered. This method calls a portlet method with the organization id as parameter. The backing method, retrieves all Users of that organization, converts the list of users to a JSON string and returns tis string to the portlet. The portlet iterates over this array and fills the second SELECT with OPTION elements. 

Step 1: Prepare the backend

Your portlet class should be a subclass of com.liferay.util.bridges.mvc.MVCPortlet. This allows you to implement the method "serveResource", which is specified in the JSF 286 specification. It allows you to access ressources of any kind in your portlet. One of the reasons why we use this method here is that it allows us to get a javascript representation of a java.util.List by using JSON. Here is the code:


@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException {

//get the parameter
String organizationString = resourceRequest.getParameter("organizationId");

long orgId= Long.parseLong(organizationString);

try {
  //get all users of the organization
  List<User> organizationUsers = UserLocalServiceUtil.getOrganizationUsers(orgId);

  //let JSON do the conversion work
  String jsonString = JSONFactoryUtil.serialize(organizationUsers);
//write string to the output stream and we´re finished resourceResponse.getPortletOutputStream().write(jsonString.getBytes()); } catch (SystemException e) { e.printStackTrace();  } }


All the magic happens when calling JSONFactoryUtil.serialize : JSON creates a string representation of our list for us. This string is passed back to the portlet and that´s all we have to know for now.


Step 2: Implementing the onClick method

After the backend is ready and waiting for our calls, we will now implement the ajax call. Note that everything we do is working out of the box in Liferay 6 (didn´t test it on Liferay 5): no need to install anything else. So, here is the javascript code:
<portlet:resourceurl var="resourceUrl"></portlet:resourceurl>

<script language="JavaScript" type="text/javascript">

function fillUsers() {
  var select = document.getElementById("<portlet:namespace />orgSelect");
  var organizationId = select.options[select.selectedIndex].value;
  jQuery.get('<%=resourceUrl%>&organizationId='+organizationId,

function(data) { 

  var parsedJSONObject = jQuery.parseJSON(data); 
  var usersList = parsedJSONObject.list; 
  var usersSelect = document.getElementById("<portlet:namespace />usersSelect");
  //delete all old options
  usersSelect.length=0;
  for (var i =0; i < usersList.length; i++){
    var option = document.createElement("OPTION");
    option.text = ''+(usersList[i].fullName);
    option.value = ''+(usersList[i].userId); 
    usersSelect.options.add(optn); 
    }
  } 
);
}
</script>

Lets go through this. First, register a resource URL that is pointing to the method we created in our backend. This method is called by using jQuery.get() which fires an ajax request and calls the registered function when it receives an answer. After the data is received, a call to jQuery.parseJSON(data) parses the JSON string into a usable javascript object. This javascript object consists of a main node called "list" that contains all Users objects. You can now access these objects by calling their properties like this: usersList[i].fullName.

If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

How to add and remove OPTION Elements for HTML SELECTs

This might be something you´ve read 1000 times in other blogs, but I am doing it for the third time in two weeks, so I am going to write it down. This is how you remove all OPTION elements from an HTML SELECT Element (Liferay version):

var element= document.getElementById("<portlet:namespace />theId");
element.length=0;

And this is how you add a selected OPTION Element:


var option= document.createElement("OPTION");
option.text = 'Your text';
option.value = 'Your value';
option.selected = true; 
element.options.add(option); 


If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

6/03/2011

The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

Yet another exception I came across. When you get an exception like this:


The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application


Then your server probably doesn´t have the JSTL libs. Just go to this page, download the api and the implementation, put it in your servers lib dir and that´s it.


If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

Exception: The method XYZ of type ABC must override a superclass method

The method processAction(PortletConfig, ActionRequest, ActionResponse) of type ConfigurationActionImpl must override a superclass method ...


if you get an Exception like this when trying to use @Override on a method that is implementing an interface method, eclipse doesn´t care and you can´t get your ext to build and deploy ... then you have to change the build.properties (you will find it in the root folder of your plugins - sdk):

ant.build.javac.source=1.5
ant.build.javac.target=1.5
should be
ant.build.javac.source=1.6
ant.build.javac.target=1.6

Java 1.5 allows @Override only for abstract classes, not for interfaces.


If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

This Blog is Plus-One-abble :)

Google started some days ago its new "Plus 1" Feature, which allows you to recommend internet ressources. So, if you see this at the end of a blog post:


then click it - this will help other users find this blog. It´s like the facebook "I like" Button, but it directly affects googles search results. I am very curious how this will work in the end.

So ... I am going to read into jQuery now. Expect to read a lot of jQuery - related posts in the next days :)




If you like this blog it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

6/01/2011

An Overview of Liferay Services - Part 2


This is Part 2 of an overview about all Liferay Services. If you want to read the other posts, take a look here.



How to get the class name id of your entities

Whenever you query the liferay database for entities you will come across the fields classNameId and classPK. This is - for example the case in assetEntry or expandoValue. Those two values tell you which entity class and which entity is referenced. The entity class is mapped by its classNameId. 
You can query for the class name id by using ClassNameLocalServiceUtil and pass the name of your class. The table contains all classNames, even the ones from your own services.


table name: classname
entity: ClassName
Service class: ClassNameLocalServiceUtil


How to get the data, the Asset Publisher displays

If you are using the asset publisher to display dynamic lists consisting of the assets you created you will notice, that the asset publisher doesn´t operate on the assets directly but instead on an entity called "AssetEntry". AssetEntries are automatically created for every asset, the asset publisher can display. So if you intend to modify the values the asset publisher displays and you don´t want to midify the asset publisher directly, take a look here.



table name: assetEntry
entity: AssetEntry
Service class: AssetEntryLocalServiceUtil

How to get Tags that you use to tag assets.

If you are tagging Liferay Assets (Documents, Web Contents, etc), Liferay creates an AssetTag entry for every tag you use. If a tag gets used multiple times, an internal counter is incremented (assetCount). This table helps you to get an overview of all tags used in a community or organization. It allows you to give the User an overview about all already used tags.




table name: assetTag
entity: AssetTag
Service class: AssetTagLocalServiceUtil





Here is the summary

Model DescriptionLiferay ServiceTable Name
ClassName IdsClassNameLocalServiceUtilclassname
AssetPublisher dataAssetEntryLocalServiceUtilassetentry
All available tags in LiferayAssetTagLocalServiceUtilassettag


If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

Beginners Guide to Liferay Web Contents - Part 2

I´ve created a post some days ago where I wrote about creating a Web Content. If you don´t know what a Web Content is, then please read this post first:


Today I am going to tell you how you can display multiple Web Contents in different kinds of ways without programming.

Liferay offers a lot of powerful features that will help you display your content on your portal page. The Portlet used the most is the "Asset Publisher". The Asset Publisher does exactly what its name implies: it publishes all kinds of assets. That may be Web Contents, Documents, Blog Posts etc etc. Today we will just care about displaying Web Contents - those Web Contents that we created in the last post. To add an Asset Publisher to your page, click on "Add" - "Asset Publisher":




This will place an unconfigured Asset Publisher on your portal page. Don´t get confused - in the beginning, the Asset Publisher will display ALL assets, it finds. So it may look a little crowded on your page.

As soon as you added the Asset Publisher, enter its configuration menu. You will notice that there is a lot you can change and tweek. I won´t explain all of the configuration items here, instead I am leading you directly to a configured results page. 
First click on "Asset Type" and select "Filter". This control lets you select the asset types, your asset publisher displays. Move all asset types to the right ("available"), except for "Web Content".


This will configure the Asset Publisher to only display Web Contents. The next thing we will configure is HOW the asset publisher displays its assets. Scroll down to the Display Style selection and select "Title List". This will select a different displaying JSP that will only show a title list. 
A quick note: You can create your own display styles by following this little tutorial:


The last thing we will do, is to select the metadata to display. Scroll to "Show Metadata" and select "Author" and "Publish Date":


This is all for now. Click on "Save", close the asset publisher configuration and you should see something like this:


As you can see, the Web Content we created the last time is displayed with its name, the Author and the Publish Date. If we had created more than one Web Content we would see all of them here. The Asset Publisher is a very powerful and flexible instrument to display content. In all projects I have participated until now, the asset publisher was one of the key instruments to fullfil the customers requirements. It is also very effective in actually convincing the customer to use Liferay. Just use these two tutorials and show them how easy it is to set up a flexible, working CMS.



If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.