Samstag, 19. April 2014

How to show a portlet on every page / layout

If you want to show a portlet on every layout in our portal, you can simply add it´s portlet id to your portal-ext.properties.
Do it like this:

layout.static.portlets.all=your-portlet-id
Once done, your portlet should be available on all pages. If you want to prevent users from deploying portlets manually you can set the following property in your liferay-portlet.xml:


<system>true</system>

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.

Donnerstag, 6. Februar 2014

How to put your document library folder under workflow control programmatically

If you want to create document library folders (dlfolder) programmatically, you can do this very easy by calling
DLFolderLocalServiceUtil.addFolder(userId, groupId, groupId, false, 0, "Folder title", "Folder description",false, new ServiceContext());
That´s just one line of code and you´re done. But what if you want to put your folder under workflow control? Liferay offers the possibility to connect assets in your folders to specific workflows. So as soon as you upload a basic document for example, the workflow will be started.  You can do that manually when you select your folder and click on "Edit":



Wouldn´t it be nice it that could be done programmatically ? Liferay source code comes to the rescue ! This is how they do it. First, set the file entry types override:
dlFolder.setOverrideFileEntryTypes(true);
dlFolder = DLFolderLocalServiceUtil.updateDLFolder(dlFolder);
Then you need to query the DLFileEntryType table for the FileEntryType you want to set up a workflow for. Next, you need to set the DlFileEntries for the folder:
long[] fileEntryTypeIds = new long[] { basicDocumentType.getFileEntryTypeId() };
DLFileEntryTypeLocalServiceUtil.setDLFolderDLFileEntryTypes(dlFolder.getFolderId(), fileEntryTypeIds);
Next is a query to get the process definitions you want your folder and the fileEntryType to connect with:
List<WorkflowDefinition> activeWorkflowDefinitions = WorkflowDefinitionManagerUtil.getActiveWorkflowDefinitions(companyId, "Your Process Name", 0, 100, null);
And last but not least you need to add a workflow definition link:
WorkflowDefinitionLinkLocalServiceUtil.addWorkflowDefinitionLink(userId, companyId, groupId, 
DLFolderConstants.getClassName(), dlFolder.getFolderId(), basicDocumentType.getFileEntryTypeId(),  name, version);


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.

Montag, 3. Februar 2014

How to show a JSP full-screen in liferay

Just answered this question to a developer on stackoverflow, so I just wanted to share it in my blog. If you want to access a JSP in full-screen mode, without showing anything of the liferay portal the JSP is deployed in, you can do the following:


Create a portlet and inside the portlet, create a servlet. This has the nice advantage that you can access your JSP by a URL like http://localhost:8080/your-portlet/your-servlet. Just think about a nice name and you will come up with a dozen business cases. Anyway ... inside your servlet you can now do a forward to your JSP and this JSp will then be displayed in full-screen. Please note that now you don´t have access to the liferay request context - no themeDisplay for example.



Creating the forward in your Servlet is pretty simple. Just add the following:

String forwardJSP = "/your-jsp.jsp";
RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher(forwardJSP);
requestDispatcher.forward(request,response);

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.

Mittwoch, 15. Januar 2014

Comparing Primefaces, ICEFaces and Richfaces with Google Trend

One thing that I´ve notices in the last two years was that primefaces pretty much eats up all the other JSF frameworks. Nearly all my clients moved away from ICEFaces towards Primefaces. So I just entered some data into Google Trends which shows us the interest of people into those technologies. As you can see, primefaces now has more than double the interest compared to ICEFaces and Richfaces combined. Well I know that it is only the search queries that people entered into google but I think that it exactly shows my work experience for 2012 and 2013: Everyone is switching to primefaces now.

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

Freitag, 10. Januar 2014

How to open a modal dialog in Liferay

If you want to create modal dialogs (a popover) in liferay you can use the AlloyUI modal component. This component allows you to refer to complex DIVs and pop them over the current window. You can do this without having to reference any additional libs.

Just add this and you will see the content of the 'popupContent' popping up:


var modal = new A.Modal(
{
bodyContent: A.one('#popupContent'),
centered: true,
headerContent: '<h3>This is a header </h3>',
modal: true,
render: '#modal',
zIndex: 1100,
height: 700, 
width: 950
}
).render();

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.

Mittwoch, 8. Januar 2014

How to setup the activity monitoring console for Talend

I started using Talend 5.3 a few days ago and one of the things I´ve spend most of my time with was the activation of the activitiy monitoring console (AMC). Even though there is a lot of configuration out there, there is no clean documentation what to do when you have a clean Talend 5.2 installation.


This is what you have to do to activate and use it:

1) Create database tables
2) Activate it in your Talend Studio
3) Activate it in your Talend Studio AMC perspective
4) Activate it in the Talend Administration Center (TAC)


Create the AMC database tables


The AMC tables are not created by default. They don´t exist and you have to create them manually to use them. You could use files instead but then you can´t use it in your TAC´s dashboard which only works with database tables.

Thankfully, Talend already has a tutorial that shows you how to create the database tables. You just have to know where it is. Here it is :


When you´ve finished this tutorial, you will have three database tables "logcatcher", "statcatcher" and "flowmetercatcher". LogCatcher is responsible for catching Exceptions and Warnings. Use it to build your own logging service for example. StatCatcher contains logging information for the processes you run.
FlowMeterCatcher contains information for specially monitored connections (like database calls).

Activate AMC in your Talend Studio

To activate AMC in your Talend Studio you can either activate it in your project or activate it for one individual jobs only.To activate it for the complete project please click on
File -> Edit project properties -> Job Settings -> Stats & Logs.
Select all checkboxes  so that Logs, Statistics and volemetrics can be catched. Check "In Database" and configure the database connection that you want to use.

After that please check that the AMC is active for the projects that you´re working on. This can be done by activating "Use project settings".

Alternatively you can activate the AMC for several jobs only. Look under "Stas and Logs" in your job view. If you configured AMC in the project it is sufficient to check "Use project settings" here,

After you´ve done that, your Talend Studio is now able to provide monitoring infirmation. What you need to do now is to configure your Talend Studio to visualize this information.

Activate AMC in your Talend Studio AMC perspective

Enter the AMC perspective in your Studio. It doesn´t yet show logging infos and needs to point to the three database tables we´ve created earlier. Please click the following : Fenster -> Benutzervorgaben -> AMC -> Datasource Type


Check "Database" and click on "Add". Give it a name and configure the database so that it accesses the AMC Data.

After that you have your AMC Information visualized in your Talend Studio. This is something that you need to do for every user of the Talend Studio: It is not possible to synchronize it over SVN.

Configuration of the Talend Administrative Console

The Talend Administrative Console (TAC) is able to show just the same data the Talend STudio does. To be able to display it, you need to configure your database connection, first.
Click on Dashboard -> Connections and select "Add".Enter all database connection details , including the database tables.
If this doesn´t yet work, then please check if you have a "localhost" URL under Settings -> Configuration -> Dashboard.  If so, please replace it with your actual server URL or server name.

After doing so, you should now see the AMC in the TAC.




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.

Dienstag, 7. Januar 2014

How to create AlloyUI reusable methods

When you are writing as much AlloyUI code as I do, you will certainly come to the situation where you want to reuse your code. Gladly, YUI3 (the foundation for AlloyUI) allows that. You can create your own modules and register them statically so you can call them from different parts of your application.


The key part is the "add" function.  It allows you to register your new module with all the methods, that you want to add. 

YUI.add('your-registered-module', function (A) {
  A.YourModuleObject = {
    yourMethod: function () {
      alert('Hello World');
  }
});

Do this at the beginning of your file and you can add your method in your code using this:
YUI().ready(
'your-registered-module',
  
  function(A) {
 A.one('#myButton').on('click', function(event) {
  A.YourModuleObject.yourMethod();
  });
Explanation: In this case we attach our hello world method to a button. When the button is clicked, our reusable method gets called and send the alert.

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.