Tuesday, July 31, 2007

Popup windows in JSF

Is is possible to raise a popup window in Java Server Faces (JSF) using Javascript, more or less the same way as in HTML.

This example shows how this can be done with a commandButton.

<h:commandButton value="Press me to bring up a popup window" onclick="window.open('popup.jsp', 'popup_window')" />

This exact method won't work with a commandLink, because this does not offer an onclick option. However the mouseup event can be used instead:

<h:commandLink onclick="window.open('popup.jsp', 'popup_window')">
    Press me to bring up a popup window
</h:commanndLink>

Of course, both commandButton and commandLink items need to be enclosed in a form element. This means that the form will be submitted when the commandButton or commandLink is pressed/clicked. In order to avoid it, we have to return false from within the onclick or mouseup attribute.

<h:commandButton value="Press me to bring up a popup window" onclick="window.open('popup.jsp', 'popup_window'); return false;" />

Wednesday, July 18, 2007

Javascript context menus

With Javascript it is possible to add a context menu to an object (ie a menu that displays on right-click). However, on Firefox, right-clicking on an object with a custom context menu will show both this menu and the normal Firefox context menu. The Firefox context menu is displayed on top of the custom menu, so in order to access the latter, you need to click somewhere else on the page, in order to access the custom menu.

This behaviour can be overridden by selecting the following options:
Edit → Preferences → Content → Advanced (next to Enable Javascript) → Disable or replace context menus.

Sunday, July 1, 2007

Ubuntu: Multisession DVDs

At the time of writing this, Gnomebaker supports writing multisession CDs, but not DVDs. This extra functionality is provided by K3b, but this is a KDE application, and installing KDE applications on a GNOME-based distribution is not always desirable.

There is however a very simple-to-use command line utility that can be used to create a multisession DVD disc, append data to it and finalize it (and the disc is fully-readable before finalization). This utility is called growisofs and its functionality can be summarized as follows:

Creating a multisession disc
growisofs -Z /dev/dvd -R -J /path/to/file1 /path/to/file2 ...

The -R and -J options define that the Rock-Ridge and Joliet extension should be used (whatever that means....). /dev/dvd should be substituted with the appropriate value for the DVD device (eg in my case it is /dev/cdrom).


Appending data to a multisession disc
growisofs -M /dev/dvd -R -J /path/to/file1 /path/to/file2 ...

The only point that needs caution here is that, when adding data to a multisession disc, you have to use exactly the same options as with when creating the disc.


Finalizing a multisession disc
growisofs -M /dev/dvd=/dev/zero