If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Thursday, June 25, 2009

debugging with maven2 jetty plugin

Here a method I found which works (just for my own record).

Step 1
Go to the Run/External Tools/External Tools ..." menu item on the "Run" menu bar. Select "Program" and click the "New" button. On the "Main" tab, fill in the "Location:" as the full path to your "mvn" executable. For the "Working Directory:" select the workspace that matches your webapp. For "Arguments:" add jetty:run.

Move to the "Environment" tab and click the "New" button to add a new variable named MAVEN_OPTS with the value:

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y

If you supply suspend=n instead of suspend=y you can start immediately without running the debugger and launch the debugger at anytime you really wish to debug.

Step 2

Then, pull up the "Run/Debug/Debug ..." menu item and select "Remote Java Application" and click the "New" button. Fill in the dialog by selecting your webapp project for the "Project:" field, and ensure you are using the same port number as you specified in the address= property above.

Now all you need to do is to Run/External Tools and select the name of the maven tool setup you created in step 1 to start the plugin and then Run/Debug and select the name of the debug setup you setup in step2.

From instructions provided by Rolf Strijdhorst on the Maven mailing list

Stopping Jetty

In order to stop the jetty server the "Allow termination of remote VM" should be checked in debug dialog in Step 2. When you have the jetty server running and the debugger connected you can switch to the debug perspective. In the debug view, right click on the Java HotSpot(TM) Client VM[localhost:4000] and chose terminate. This will stop the debugger and the jetty server.

Wednesday, June 24, 2009


Today I was listening to music on youtube and I suddenly got the idea to build an app that
would enable users to add a playlist just like Itunes. Guess what...


It already exists ;-) It really looks web2.0 and since I've installed ORB on my desktop I can open this application through the Wii. So next time I'll be listening my favourite songs on television.


Tuesday, June 23, 2009

Bug in Google Chrome

I was trying to view a xml file in Chrome today after updating to the most recent version and to my surprise it did not render the xml properly like is the case in most other browsers. I hope this bug will be fixed soon.

Thursday, June 18, 2009

Internationalization with GWT

I ran into a exception yesterday saying "no resource found for key xxx". I double checked my properties file but the key/value was there. Scanning the gwt forum for the same issue resulted in 3 hits but no answer to my problem.

My properties file looked like:


Apparently you need to leave spaces between the key, = and value so when i changed the snippet above to

user = User
home = Home

everything worked.


Wednesday, June 17, 2009

Google AppEngine and GWT

I finally started exploring google app engine. I'm planning on giving a knowledge session later this year as part of my goals for this year. I only spent a few days experimenting and with no prior knowledge I'm quite satisfied with my progress. Uptill now i created a new app engine project using JDO for persistence. I hope JPA does not turn out to be a better choice in the end.

Anyway, i was able to create a userform widget (composite) which enabled me to add a new user and another usersform widget which presented all users. It took me a while to understand how the Async interface worked since the return type can only be 'void'. Luckily a quick look at the AsyncCallback.java reveiled how it all works.

Below some screenshots of how it works:

Another thing which takes getting used to is page navigation with GWT. You only have one html page representing your EntryPoint. So what you basically do is dynamically adding and removing your widgets in the pagecontainer.

Next weeks I will write more about my findings.


Wednesday, June 10, 2009

Video DownloadHelper

Yesterday i installed a really nice plugin for firefox which enables me to download movies from all kinds of websites like Youtube. It also automatically converts the movie into MPEG4. Now if I find a movie worthwile to watch in good quality, i just download it first and can watch it later on. Even without an internet connection ;-)


Thursday, June 4, 2009

cocoon 2.2 block handling all file reading

I've seen many cocoon apps where they use properties in the sitemap to for instance dynamically construct the "src" attribute of a generator or reader. I also did not want to pollute my sitemap with multilevel selectors to get the job done. Well, there are more elegant ways to accomplish this. I used a combination of
  • the cocoon spring configurator
  • sitemap
  • flowscript
  • springbean
Screenshots below should make clear how i setup a (shared) block for ally upcoming publications to handle file reading.

Configure a bean with all knowledge about the repository containing images, xml, ...

Bean configuration:

Java Bean snippet:

Sitemap snippet:

Flowscript snippet:
(which calls my javabean)

So what basically happens is that the sitemap delegates the construction of the src attribute to a flowscript function. This flowscript call's my javabean based on the parameters it receives from the sitemap. Then another pipeline is invoked which
- generates the xml file in case of calling the xml pipeline
- reads the file from disk

Robby Pelssers

escaping html with xslt

Ok... suppose you get some xml from a customer which looks like:
<![CDATA[T<sup>j</sup> >= 25]]>

You could easily use the attribute disable-output-escaping if you only needed to put the value between a <td>. But what if you needed to transform it into something like

<a href="#footnote-1">T<sup>j</sup> >= 25</a>

In this case your last stylesheet can't have a matching template like the one below since that would mean getting rid of the anchor tag.
<xsl:template match="td">
<xsl:value-of select="." disable-output-escaping="yes"/>

So when you KNOW what part of the xml can contain html tags, you can surround that data with a meta tag which you will use in the final transformation before serializing to xhtml.

So let's transform the above snippet to:

<nxp:escape>T<sup>j</sup> >= 25</nxp:escape>

<xsl:template match="footnote">
<a href="#footnote-{position()}"><xsl:apply-templates select=./node()/></a>

<xsl:template match="@*|node()">
<xsl:apply-templates select="@*"/>

So now we get

<a href="#footnote-1">
<nxp:escape>T<sup>j</sup> >= 25</nxp:escape>

In our last stylesheet we only need to to the following:

<xsl:template match="nxp:escape">
<xsl:value-of select="." disable-output-escaping="yes"/>

<xsl:template match="@*|node()">
<xsl:apply-templates select="@*"/>


cocoon 2.2 experience

I had to rewrite a cocoon application from scratch over the last few days because the xml schema used for their productinformation was completely redesigned on my advice.

This meant i could not reuse the existing transformations. This was an exciting challenge so I've spent many hours (about 70) to get the job done. The first thing I did was creating a cocoon block that transformed the original (messy) xml file to validate the new schema. Next in line I created a cocoon block which will be responsible for reading all files from their repository (unix filesystem).

I'm pleased with the end-result so here comes a first screenshot.

I also am going to share the lessons learned from this huge cocoon annex xslt job among which:
- how handling escaping html (cdata) in a smart easy way.
- pitfalls encountered
- how creating nice popup panels
- ...

Robby Pelssers

Tuesday, June 2, 2009

problem with characterencoding of nonbreaking spaces

This weekend I ran into the issue that internet explorer did not render non-breaking-spaces (&#160;) correctly, while firefox did.

Explicitly setting the charset header solved it ;-)

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />