WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.
As you're probably well aware of, there were several important releases this week. First, NetBeans 5.5 was
released. This has been covered extensively by other Sun bloggers
so I won't repeat the highlights here - just check it out if you haven't already.
Second, a number of add-on packs for NetBeans 5.5 were released. A pack is a cluster of plugins.
One of these is the
Visual Web Pack, which basically bundles all the visual web page design functionality from Creator into NetBeans. With this, you can create pages Creator style alongside other NetBeans features, such as the profiler, or the UML tool, or the enterprise XML support.
There's another big reason why even Creator users should try the visual web pack (which is in technology preview state, not a final release like NetBeans 5.5.). It offers new support for Java 5 language features, as well as Java EE 5 support. I took it for a quick testspin and thought I would show it in action here.
If you download NetBeans 5.5, and then the Visual Web Pack installer, you can create Visual Web Projects. Unfortunately, out of the box, it will only offer to create J2EE 3 and J2EE 4 projects. The reason for this is that NetBeans is only bundled with the Tomcat web container, and Tomcat is not adequate for Java EE 5 projects. Thus, the trick is to also download a Java EE 5 capable app server such as Glassfish or its cousin, the Sun Application Server. Once you've done that, and you select it as the target in the new project dialog, you are able to create a Java EE 5 project. Hopefully we'll have everything ready as a single bundle so that out of the box, you're defaulting to Java EE 5 projects and Java 5 source. Here's the configuration portion of the New Project wizard (click Manage to register additional web servers).
Let's create a simple web app which utilizes Java 5 features. It will be a simple page which lets you provide the name of a Java class, and then the methods (possibly generic) of the class are displayed. Here's what the web app looks like in the designer:
Here's the button click event handler:
Note that we simply use the
error method to log messages for the page; these are all displayed in the group message component. This is a very simple way to log messages for ourself during debugging. You should always have a Message Group component, on every single page of your application, during development. This will make it immediately obvious if you have validation errors or other problems that might otherwise silently occur and leave you scratching your head.
When we run and try it with some sample data, here's the result which shows Java 5 language features in action:
The next step is to play with Java EE 5 features mixed with JSF. That will have to wait for another day; I've gotta get back to my day job, which I'll blog about soon.