Web Based Ajax Terminal

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.

Screen shot 2009-10-20 at 8.47.11 PMCode

    <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.

This entry was posted in Developer, Java, PrimeFaces. Bookmark the permalink.

4 thoughts on “Web Based Ajax Terminal

  1. İs there any wrong with handleCommand method, Cağatay?
    Two same condition check?

    if(command.equals(“date”))
    3.
    return “Hello” + params[0];
    4.
    else if(command.equals(“date”))

  2. Pingback: primefaces – JSF und YUI « Orgeltom's Blog