Search This Blog


Wednesday, September 29, 2010

JRebel rocks!

Today I installed JRebel because I was tired of all the Republish stuff when working with JBoss in Eclipse. I am glad I did! I am not sure how much time it saved me exactly (when working for 4 hours) but looking at the JBoss server.log showed the following:

Maybe a little too optimistic, but a republish costs one minute at minimum. At 40 redeploys, this saves me about 45 minutes. This is 1.5 hour for a full work day!

Monday, September 27, 2010

Flex4 DateField bug when using locale nl_NL

When porting a Flex 3 application to Flex 4 (4.1 SDK), I had a little issue with my DateField components. The selected date in the DateField component did not have any formatting applied to it and when accessing the selectedData property in Actionscript returned null. For example selecting 7th September 2010 resulted in '0709092010' but it should be '07/09/2010'.

Some searching revealed that this is a known bug which is hopefully resolved in SDK4.5. See for more details.

A quick workaround is to specify the formatString explicitly in the DateField component as in the following example:
<mx:DateField id="date" formatString="DD/MM/YYYY"/>
<s:Button click="trace(date.selectedDate);"/>

Friday, September 24, 2010

FlexCamp presentation

Wednesday 22nd of September, I gave a presentation for the Dutch Flex User Group at FlexCamp at Adobe in Amsterdam. You can find this presentation below:

Friday, September 3, 2010

Printing in Vaadin

In one of my recent projects for one of our clients, I have used the Vaadin framework to develop the application. One of the requirements of this application was to print certain content. I basically evaluated three possible solutions to implement this functionality:

  1. Create a new window with content specifically designed for printing and use the JavaScript print() method to print the contents of this window;
  2. Create a PDF with the printable contents and open this PDF in a new browser window;
  3. Create a PDF with the printable contents and use the Embedded and Window components to display the PDF.

I found option 1 not compatible and consistent enough between browsers. To create a consistent look&feel of the printable contents I used PDF. One way to display this PDF to the end-user is to open a new browser window. Unfortunately this was hindered by popup blockers which is not acceptable to end-users of the application.

Option 3 involved using an Embedded component to display the PDF inside a native Vaadin popup window (which is a regular div). This way, the printable contents are always consistent (because PDF is used) and the popup with the PDF contents is not hindered by browser popup blockers because the popup is just a regular div. By using this method, the print window also integrated nicely with the visual appearance of the rest of the application. The following code demonstrates how to implement this functionality:
* This class creates a PDF with the iText library. This class implements
* the StreamSource interface which defines the getStream method.
public class Pdf implements StreamSource {
private final ByteArrayOutputStream os = new ByteArrayOutputStream();

public Pdf() {
Document document = null;

try {
document = new Document(PageSize.A4, 50, 50, 50, 50);
PdfWriter.getInstance(document, os);;

document.add(new Paragraph("This is some content for the sample PDF!"));
} catch (Exception e) {
} finally {
if (document != null) {

public InputStream getStream() {
// Here we return the pdf contents as a byte-array
return new ByteArrayInputStream(os.toByteArray());

And the code for displaying a popup with the actual PDF viewer:
Window window = new Window();
((VerticalLayout) window.getContent()).setSizeFull();
Embedded e = new Embedded();

// Here we create a new StreamResource which downloads our StreamSource,
// which is our pdf.
StreamResource resource = new StreamResource(new Pdf(), "test.pdf?" + System.currentTimeMillis(), this);
// Set the right mime type


A full, working example including PDF generation, can be found here. The example project demonstrates displaying the PDF with and without a popup.

What is your experience with printable content in a Vaadin application?


On September 22nd, the Dutch Flex User Group organizes FlashBuilderCamp at Adobe in Amsterdam, The Netherlands. I will be giving a session about presentation patterns and how to implement these patterns with the Swiz framework. Swiz is a micro-architecture and dependency injection framework for structuring Flex applications which I used in a couple of major Flex application.

Make sure you attend the conference. Entrance and dinner is free. More information can be found at Flugr.