7/26/2012

Creating the URL of a community or organization

Ok, this is a short one and it is more like a reminder for myself.
This is how you get the relative URL that points directly to a community or organization page:


public static String createLinkToGroup(Group group, Layout layout){
  boolean privateLayout = layout.isPrivateLayout(); 
  String privateSelector = privateLayout ? "group" : "web";
  String link ="/" + privateSelector + group.getFriendlyURL() + layout.getFriendlyURL(); 
  return link;
}


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.

7/24/2012

AlloyUI: How to get the parent in TreeViewDD

If you are using the AlloyUI TreeViewDD component to visualize a hierarchic structure, you might come to the point that you want to process the information that is created when you drag and drop items in your tree. One question that kept bugging me for days was how to get the information that Node A was dropped into Node B.
Well, here is the solution:


var tree1 = new A.TreeViewDD({
  boundingBox : '#tree1',
  children : children,
  on: {
    drop: function(event) {
      var selectedNode = tree1.getNodeById(selected);
      var parent = selectedNode.get('parentNode');
      var parentId = parent.get('id');
    },
    lastSelectedChange: function(event){
      var id = event.newVal.get('id');
      selected = id;
    }
}

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.

AlloyUI: How to send an AJAX request

Just a short instruction on how to send an AJAX - request with AlloyUI. First you need to create an MVCPortlet so that you can fire to distinct methods.


Create an action method like this:

public void somethingHappensHere(
  ActionRequest actionRequest, 
  ActionResponse actionResponse) throws IOException, PortletException {
}
In your AlloyUI page add the following to a button of your choice. The variable "myActionURL" should point to your "somethingHappensHere" method in your portlet.
var url = '<%= myActionURL.toString() %>';
A.io.request(url,{
//this is the data that you are sending to the action method
data: {
   <portlet:namespace />id: selected,
   <portlet:namespace />name: name,
},
dataType: 'json',
on: {
  failure: function() { //do something },
  success: function(event, id, obj) { //do something else}
}
});



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.

7/23/2012

How to get the configured SMTP Host of Liferay

This is a simple one but I want to keep it so that I don´t have to look it up again in the future.
This is how you get the SMTP host that is configured in Liferay
String smtpHost = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST);


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.

7/19/2012

What to do when Liferay´s PDF function doesn´t render the images

When you´ve successfully installed Open office on your machine and you activated the Liferay - OpenOffice integration you are able to let users convert your Web Contents to PDF.


This works more or less, the PDFs you get won´t win a price. But at least they contain the pictures you´ve included. They don´t ? Well ... read on.


If your PDF files don´t contain any pictures then the reason might be that your OpenOffice is installed on a machine behind a proxy. To solve this, simply add the following snippet to the file


/usr/lib/openoffice/basis3.2/share/registry/data/org/openoffice/Inet.xcu

<prop oor:name="ooInetProxyType" oor:type="xs:int">
   <value>2</value>
  </prop>
  <prop oor:name="ooInetHTTPProxyName" oor:type="xs:string">
   <value>YOUR_PROXY</value>
  </prop>
  <prop oor:name="ooInetHTTPProxyPort" oor:type="xs:int">
   <value>80</value>
  </prop>
  <prop oor:name="ooInetNoProxy" oor:type="xs:string">
   <value>localhost;127.0.0.1;YOUR_PROXY;YOUR_MACHINES</value>
  </prop>
If you do this then liferay should be able to render its PDFs with pictures included :)


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.