Skip to main content

Phobos and NetBeans 5.5

Posted by robc on November 10, 2006 at 3:05 PM PST

A couple of weeks ago we started showing in public the new set of NetBeans plugins for Phobos: I did a presentation and a demo of Phobos at the Colorado Software Summit conference and Ludovic Champenois demoed the plugins at the Ajax Experience conference. Here I'm going to give you a quick tour of the new features. If you are not familiar with Phobos, I recommend reading the overview document on our web site. We envision these plugins as the way people will write Phobos applications. Of course, you can also do so manually, creating the right directory structure, etc., but as you'll see here, there are some distinct advantages to using an IDE, especially when you are new to the framework.

To start, there is a Phobos application wizard that you can use to create your first Phobos app. Here's a screenshot:

phobos_netbeans_01.jpg

Once the wizard has done its job, you get a Phobos application project with the appropriate logical structure displayed in the "Projects" pane:

phobos_netbeans_02.jpg

The main editor pane is open on a ejs file, i.e. a view. Using the jMaki palette on the right, we drag-and-dropped two controls on the view, a Dojo clock and a Yahoo Map widgets. Thanks to jMaki, there is a uniform interface for widgets, so mixing components from different toolkits is easy.

If you look closely at the toolbar, you'll notice that the application is running in debug mode. To make it easier to test your application, in debug mode we run it inside a test container that runs in the same process as NetBeans. It's not simply a mock container though, because, thanks to the Grizzly HTTP connector, we get a real HTTP server which we can use to serve browser requests. As a result, you can test your application interactively in the browser and make changes to it as it runs:

phobos_netbeans_03.jpg

Any changes you make to any script or view is immediately reflected in the running application. We think that this compilation- and deployment-free approach to building applications really brings the advantages of scripting to the forefront. For deployment, we are working on adding functionality to the plugin to build a regular web application (i.e. a war file) out of your app, so you can deploy it on any application server. We are also going to make it easy to create a web application project that uses Phobos functionality side-by-side with other APIs, like JSP and JSF.

Developing your application interactively is fun, but what if you need to do some real debugging? Isn't JavaScript hard to debug, you may ask? No, all you need are good tools. With a little bit of magic and a lot of work, we wrote a JavaScript debugger for NetBeans that is attached to the scripting engine inside the running server, so you can set breakpoints in your JavaScript code and see what's going on:

phobos_netbeans_04.jpg

As you can see at the bottom of the picture, the call stack pane displays the server-side JavaScript call stack, and the local variables pane lets you inspect JavaScript objects. Since most of the framework code is in JavaScript, you can set breakpoints there too and see exactly how the dispatching logic works. For that matter, you can change that logic while the application is running!

There are many more advantages to using NetBeans to develop Phobos application than I can describe here. For example, you can create a Java library that uses JPA and add it as a dependent to your Phobos project, then use entity objects as the persistence layer for your application. We have some libraries to help you with that too, by the way, more on this another time.

If you can't wait to try this out, Pramod wrote a HOWTO blog entry. Our plan is to iron out a few wrinkles in the plugins, then make them available for download as nbm files and via an update center. In the meantime, all the source code is in our publicly accessible CVS repository, so you can check it out there.

Finally, a call for help: we'd love to have an equivalent set of plugins for Eclipse. Most of the work we did to enable debugging in NetBeans would apply just as well to the Eclipse version, but we need volunteers to do some of the ground work. If you are interested, please send mail to our developer mailing list and we'll take it from there.

Related Topics >>