Monthly Archives: July 2011

Velocity Macro: Exception when getting undefined localized string

When I was playing around with localization within Velocity Macro I received some bad exception when I was trying to get a localized string whose key doesn’t exist.

“Can’t find resource for bundle java.util.PropertyResourceBundle, key”

It was even worse that the rest of my template wasn’t rendered just because of a missing localisation key. That’s pretty bad and I would rather see one non-localized key instead of nothing at all. When those localisation keys are generated dynamically these exception can come even more often if you change some value in one spot for example not thinking about that this one is used for localisation.

Read more... (220 words, estimated 53 secs reading time)

Posted in Jetspeed, Velocity Macro | Leave a comment

Add customized Like-Button to your website

I was trying to put one of those Facebook-Like Buttons onto one of my websites. Of course I didn’t want to use their style(s), but a different one that would fit into the design of my site. On the other hand the original design every one knows and also knows the meaning immediately. However, if you wanna change the style of your Like-Button than it won’t be easy!

The usual way to get your Like-Button onto your site is to go to the Facebook website and get fetch some code that you simply put onto your page. Afterwards you have a fully functional Like-Button with lots of features. You can even write a comment, once you clicked the button and are logged in to Facebook.

Read more... (556 words, estimated 2:13 mins reading time)

Posted in Javascript / HTML / CSS | 1 Comment

Servlet/Portlet Filter for Url-Rewriting

When it comes to URL rewriting the first thing that comes in mind is using the Apache config file httpd.conf. That’s generally good but has the disadvantage that your webapp cannot be installed without modifying a system file with root access, which not everyone might have. Anyway … this could look something like this:

Another nicer approach is to use this URL-RewriteFilter, which will be part of your webapp. You just need to copy the library into the lib-folder of your webapp and activate the filter in your web.xml like this:

This will filter all incoming URLs from the root, before they actually reach the webapp’s code. Check out the website for more options! If a webapp has for example the path “/my-portal/portal/default-page.psml” which points to your start page of your Jetspeed Portal, then you can access this page with “/startPage” by adding this rule to your configuration file (urlrewrite.xml) in your WEB-INF directory:

If you also want to have rewritten all your links of your website, you need to define an outbound rule. So every link within your JSP or Velocity Macro page will also point to the pretty URL. However it is important to use “response.encodeURL(…)” for all links! In other words use

for jsp-pages or

for vm-pages, otherwise they might not be send through the filter, so better mark them all :) The outbound-rule has to be defined something like this:

Posted in Apache, Java | Tagged , , | Leave a comment