Project Zero is Groovy

Although Project Zero has been out for a couple of weeks, I just started getting into it pretty heavily in the last week or so. So far, this seems like as great technology. It takes some of the best programming models and puts them into a server and API. The best part, I think, is the adoption of Java and PHP as the syntax for the server side. The integration with Eclipse is also very nice (although I am waiting for type-ahead for Groovy files). By installing the ProjectZero runtime you can get some very good samples and get up and running very quickly.

When you look at the demos, the code is pretty straight forward. The syntax is Java and HTML while the output is basic HTML. The really cool thing is the entire basis for ProjectZero is to promote a REST based architecture. So some of the more advanced samples can show that off.

Groovy file:

/*
* ============================================================================
* Licensed Materials - Property of IBM
* Project Zero
*
* (C) Copyright IBM Corp. 2007 All Rights Reserved.
*
* US Government Users Restricted Rights - Use, duplication or disclosure
* restricted by GSA ADP Schedule Contract with IBM Corp.
* ============================================================================
*/

todos = app.todos.get();
if (todos == null) {
todos = [];
}

if (request.method.get().equals('POST')) {
action = request.params.action[0].get();
if (action.equals("Add")) {
items = request.params.item.get();
if (null != items){
item = items[0];
if (null != item && item.size() > 0)
todos.add(item);
}
} else {
selected = request.params.todos.get();
for (i in selected)
todos.remove(i);
}
app.todos = todos;
}

writer = request.writer.get()

writer.write '''


Simple Todo List


Your todo items:



'''

todos.each { writer.write " "+it+"
" }
writer.write '''








'''

Output HTML:



Simple Todo List


Your todo items:











Tags: : : : :

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.