Mac Dock for JSF

Upcoming PrimeFaces 0.9.1 UI will feature a dock component that mimics the famous dock in Mac Os X in a web page. Basically a dock consists of the dock itself and the dockItems. You can have as many dockItems as you want.

Picture 2

<pre>
<p:dock>
<p:dockItem label="Home" icon="/images/dock/home.png" url="#"/>
<p:dockItem label="Music" icon="/images/dock/music.png" url="#"/>
<p:dockItem label="Video" icon="/images/dock/video.png" url="#"/>
<p:dockItem label="Email" icon="/images/dock/email.png" url="#"/>
<p:dockItem label="Portfolio" icon="/images/dock/portfolio.png" url="#"/>
<p:dockItem label="Link" icon="/images/dock/link.png" url="#"/>
<p:dockItem label="RSS" icon="/images/dock/rss.png" url="#"/>
<p:dockItem label="History" icon="/images/dock/history.png" url="#"/>
</p:dock>

Head over to the online demo to see dock live.

User IdleMonitor

PrimeFaces 0.9.0 introduced a new component idleMonitor to watch user actions and execute callbacks in case they go idle or active again. Simplest use would be as follows; suppose you want to display a modal dialog when the user goes idle.

<p:idleMonitor onidle="idleDialog.show();" onactive="idleDialog.hide();"/> 

<p:dialog header="What's happening?" widgetVar="idleDialog" modal="true"
	 fixedCenter="true" close="false" width="400px" visible="true">
	 <h:outputText value="Dude, are you there?" />
</p:dialog>

By default idleMonitor waits for 5 minutes so after this period in case user doesn’t do
anything, dialog will popup.

Ajax IdleEvent
Most likely, you would want to execute a callback on a JSF bean to do something useful like
invalidating the session. For this use case idleMonitor is equipped with idleListener. With a
simple methodexpression your idleListeners will be notified by passing an IdleEvent.

<p:idleMonitor idleListener="#{idleMonitorController.handleIdle}"/>
public void handleIdle(IdleEvent event) {
	 //Invalidate user
}

Ajax Update
IdleMonitor is also powered by PrimeFaces Partial Page Rendering infrastructure so it can update
the page after an idleListener is invoked, this is useful to notify the user what happened while they
were away.

<p:idleMonitor idleListener="#{idleMonitorController.handleIdle}"
	 	 update="message"/> 

<h:outputText id="message" value="#{idleMonitorController.msg}" />
public void idleListener(IdleEvent event) {
	//invalidate session
	msg = "Message from server: Your session is closed";
}

Online Demo
To see idleMonitor in action check out the online demo.

Worst Java Hosting Ever

Lately I had the worst java hosting experience with EATJ hosting. Very very very rude customer service, tricky hosting plans that require you pay more after purchasing an account(eg they warn you to buy more memory otherwise they close your account in 5 days even if you paid in advance for the whole month) and again very rude customer service.

So what I’ve done, even I have still some time on eatj, I decided to cancel it and go for a ubuntu VPS from another company, it turned out the be a great decision since I can install anything I want.

Anyway this entry is to warn any java developer to stay away from EatJ. Still frustrated.