Little jOOQ trick to get a List of POJOs

This took a little research. The idea is to obtain a List of POJOs generated by jOOQ using the related DAO.

In this case, we generated the PostDao and the Post POJO with jOOQ's generator. The trick is to use the mapper() method defined in the DAO to generate the List of Post instead of Result<Record>.

Active Page in Apache Wicket

A few days ago I started a new project with Apache Wicket and I'm pretty sure I'll be posting some cool stuff I'll be learning during the following days using this framework (a nice review in the future?).

Anyway, something I found quite annoying to do and that took me some time to get a hold of was telling a menu which the active item is so that we can highlight it.

Basically, you'll probably have some sort of ListView with some custom MenuItem objects and a 

<li wicket:id="myMenuElements">

Also, you'll probably have a BasePage template for the layout which your pages will extend. The trick here is to have your BasePage class constructor to require the parameters and the active class.

public BasePage(PageParameters parameters, Class<? extends Page> active){
    add(new MyHeader(active));

This way, when extending this class, you're forced to call the super constructor:

public HomePage(PageParameters params){
    super(params, HomePage.class);

Finally, and if your MenuItem uses BookmarkablePageLink for somewhere in your MenuItem code you can do something like:

final BookmarkablePageLink link = new BookmarkablePageLink("menuLink", obj.getUrl());
link.add(new Label("menuLabel", obj.getTitle()));
    item.add(new AttributeModifier("class", "active"));

One thing to note is that the getPage().getPageClass() method cannot be called until the component has been added to the page, so we can't use that from any code that is executed in the constructors.

Hope this helps some wicket n00bz like myself :-)

Font Awesome Icons in Android

Here's a small example of how to use Font Awesome in your Android apps. First of all, download font-awesome and place the fontawesome-webfont.ttf file in your assets folder. Then, add to your strings.xml file the following definitions:

Now, you'll need to set the Typeface for each widget you're going to put an icon, for example, a Button:

Since it's a font, you can control the color and size of the icons programmatically and the icons will scale automatically. The biggest downside is that the icons won't appear in the graphical layout.

Icons in the ActionBar

You can place your icons in pretty much any part of the ActionBar title or in the tabs.


ActionBar Icon

You can also customize the ActionBar title with a very cool hack. First, you'll need to create a MetricAffectingSpan like this one:

Then you change the ActionBar title on your activity onCreate method:

The result is the following:

Generate the XML

Run the following against the variables.less file in Font Awesome:

grep "\f" variables.less | awk -F\" '{ print $1 $2 ";</string>" }' | sed 's/\\/\&#x/' | sed 's/@/<string name=\"icon_/' | sed 's/:\ /\">/' | sed 's/-/_/g'

Updating Geeksphone Keon to Nightly Build

Tonight I decided to update FirefoxOS on my Keon, because the version that comes by default is, well, not too good enough for my nerves.

Anyway, the process is quite easy, on Linux at least.

Before you begin, be sure to have enabled the remote debugging option and at least 10% of battery in your Keon. 

Download the latest nightly build from Geeksphone and unzip it somewhere.

Now, add/edit the file /etc/udev/rules.d/51-android.rules with this two lines:

SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"

Put the Keon on Airplane Mode and plug it to the computer with the USB cable.

Run ./

You should get the following output:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *
< waiting for device >
sending 'boot' (3424 KB)...
OKAY [  0.364s]
writing 'boot'...
OKAY [  0.628s]
finished. total time: 0.992s
sending 'userdata' (26364 KB)...
OKAY [  2.816s]
writing 'userdata'...
OKAY [  4.909s]
finished. total time: 7.726s
sending 'system' (134304 KB)...
OKAY [ 14.387s]
writing 'system'...
OKAY [ 25.483s]
finished. total time: 39.870s
erasing 'cache'...
OKAY [  0.006s]
finished. total time: 0.006s

finished. total time: 0.001s

And there you go, a fresh FirefoxOS version.

Warning: Flashing will WIPE ALL YOUR DATA!

A jQuery Mobile Progress Bar

Been working on different apps for FirefoxOS, which I'm loving by the way.

For my latest app I've been using jQuery Mobile which, to my surprise, doesn't come with a progress bar control.

Luckily for you, here's the code to generate yours with as few lines of code as possible.

This code is being used for the landing page of this app while it loads some stuff on the background.

You can put the slider's button back by removing the .ui-slider-handle from the CSS