Liferay, Theme and Velocity variables

Here you have a table of the output of some Velocity variables used in Liferay, I’ve used the portal_normal.vm to print the value.

  • $portalUtil.getHost($request) –> localhost
  • $request.getClass().getName() –>com.liferay.portal.kernel.servlet.ProtectedServletRequest
  • $themeDisplay.getPathThemeRoot() –> /nameoftheme/
  • $full_templates_path –> volkswagenexpeience-theme_SERVLET_CONTEXT_/templates

Some interesting links:
Themes at Liferay

I will update this post as soon as possible because now I can’t finish it.

java.util.Enumeration vs java.util.Iterator

The next example print, using the standard output, all the java.lang.String Object included in a java.util.Map using a java.util.Iterator

Iterator oIterator = oMap.values().iterator();
while(oIterator.hasNext()){
String[] theParam = (String[])oIterator.next();
String theValue = (String)oMap.get(theParam[0]);
System.out.println("\n= param: " + theParam[0] + " --> " + theValue);
}

The next one use the java.util.Enumeration to print a java.util.Hashtable

if(!oHashtable.isEmpty()){
Enumeration oEnumeration = oHashtable.keys();
while(oEnumeration.hasMoreElements()){
String theParam = (String)oEnumeration.nextElement();
String theValue = oHashtable.get(theParam);
System.out.println("\n=param: " + theParam + "=" + theValue);
}
}

Notice that it needs an if to check the status of the Hashtable because the method .keys() can throw a java.lang.NullPointerException.

Java String Capitalize

When I was looking for first time the method to capitalize a Java String, I was searching in the Sun Official API but… there isn’t.

Strange not?

No problem this is the code to capitalize a Java String:

String mystring = (mystring.substring(0, 1).toUpperCase() + mystring.substring(1).toLowerCase()).trim();

You can also download it from Javamarco google code repository