PrimeFaces brings desktop terminals to the web, p:terminal is an ajax powered JSF component to execute commands defined on server side. Usage is very simple, just place the terminal and provide a command handler.
<p:terminal commandHandler="#{mybean.handleCommand}" />
CommandHandler is a simple java method taking two parameters, first one is the name of the command and second parameter is an array of command arguments.
public String handleCommand(String command, String[] params) {
if(command.equals("greet"))
return "Hello" + params[0];
else if(command.equals("date"))
return new Date().toString();
else
return command + " " + not found;
}
Terminal in Mock OS X
I’ve integrated terminal to famous PrimeFaces Mock OS X, there’s a terminal icon in the dock displaying the terminal in a dialog. Check out the terminal in Mock OS X demo. CommandHandler is the one I’ve posted above with greet and date commands.
More Demos
There’re two more terminal demos;
* Terminal in a dialog
* Full page Terminal
Aim of PrimeFaces is to create the Ultimate Component Suite to rule them all. What PrimeFaces has so far is just the beginning.
Mert Caliskan posted a simple ajax performance test comparing PrimeFaces, RichFaces and Trinidad. He used simple partial page rendering examples in demo applications which reveals PrimeFaces is 2x/3x faster than RichFaces and Trinidad. Also Alex Smirnov tested the same demo apps and got a set of different results.
Well benchmark tests usually cause debates, I’ve also done similar tests but to improve the accuracy and cause less debates I’ve created three different applications rather than using showcases. All applications are deployed on tomcat6, use server side state management and facelets for view. The box used for testing is a mac book pro 2.4 ghz with 4gb ram running snow leopard.
Let’s start with PrimeFaces.
PrimeFaces
Page: primeppr.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<head>
<p:resources />
</head>
<body>
<h:form prependId="false">
<h:inputText value="#{testBean.text}" />
<p:commandButton value="Submit" update="out" />
<h:outputText id="out" value="#{testBean.text}" />
</h:form>
</body>
</html>
Configuration: None (PrimeFaces is a lightweight library so basically there’s nothing to configure ![]()

RichFaces
Page: primeppr.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<head>
</head>
<body>
<h:form>
<h:inputText value="#{testBean.text}" />
<a4j:commandButton value="Submit" reRender="out" />
<h:outputText id="out" value="#{testBean.text}" />
</h:form>
</body>
</html>
Configuration: As far as I know disabling forceparser improves RichFaces performance, so I set forceparser to false.
Trinidad
Page: trinidadppr.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:tr="http://myfaces.apache.org/trinidad">
<head>
</head>
<body>
<tr:document>
<h:form>
<tr:inputText value="#{testBean.text}" />
<tr:commandButton id="btn" text="Submit" partialSubmit="true"/>
<tr:outputText id="out" value="#{testBean.text}" partialTriggers="btn"/>
</h:form>
</tr:document>
</body>
</html>
Configuration: I’ve disabled debug setting of Trinidad in trinidad-config.xml.
Results
For 10 requests for the exact simple use case, average processing times are;
PrimeFaces: 8.4 ms
RichFaces: 16.7 ms
Trinidad: 9.7 ms (Note that Trinidad has more optimization features like view state caching which can improve the performance even further.)
I believe these results can be realized as more accurate compared to other two tests I’ve mentioned because for my tests rather than using the different showcase apps I’ve created the same application three times with each library.
I’m glad that PrimeFaces is performing well, the reason is as a result of aiming to keep things simple. PrimeFaces has no servlet filter, html parser, custom viewhandler, custom statemananger and etc. This helps PrimeFaces to keep things clean, do less computation, use less memory and be lightweight. Even acouple of PrimeFaces users were kind enough to provide testimonials which proves it.
PrimeFaces 1.0.0.RC aka PRIMUS will introduce the new Ajax Push aka Comet features powered by Atmosphere, after doing the initial integration I’ve created a sample chat application for a demo. It’s a simple app with login and message sending capabilities powered by http-streaming. I’ll also add support for long-polling approach soon.
After creating it, I took the integration one step further and using TouchFaces, created an iPhone app as a chat client. App will also work well with other mobile devices such as Android Phones, Palm Pre, Nokia S60 and more, any handheld device with a webkit browser is supported well.
Following is a short screencast, begins with demonstrating how easy it’s to use PrimeFaces Push and then adds more flavour with the TouchFaces client. Don’t forget to watch the video in HD. You can also play with this stuff via the online demo of PrimeFaces. Mobile chat client is also available at the TouchFaces section of PrimeFaces showcase.
Last week, I gave my “Rapid RIA with PrimeFaces” talk at an event organized by London JUG. The session is recorded and available as a 90 minute podcast. Slides are also available at PrimeFaces project page and you can watch the podcast at skills matter site.
My next stop is JSFSummit 2009 where I’ll be doing an updated version of this talk in Orlando, USA. See you there!
I am pleased to announce that new version of PrimeFaces UI Components is released. Version 0.9.3 features the TouchFaces mobile UI kit, 5 new components, improved portlet support, enhanced datatable and various improvements.
See the full changelog for detailed information. Reference Documentation is also updated with 37 pages more, making it a total of 277. Additionally prime-showcase application is updated with a better looking UI.
PRIMUS
Next milestone is PrimeFaces UI 1.0.0.RC codename “PRIMUS” which will feature Ajax Push based on Bayeux protocol. Watch the teaser trailer below for more information