The Source for Java Technology Collaboration
User: Password:



Cay Horstmann

Cay Horstmann's Blog

JSF Support in Eclipse Europa and NetBeans 6.0m10

Posted by cayhorstmann on July 03, 2007 at 11:41 AM | Comments (11)

When Eclipse Europa was released on June 29 (together with the iPhone and the GPL 3 license), I wanted to know if it did anything about one of my many pet peeves: tool support for writing JSF apps. In this blog, I will compare Eclipse 3.3 and NetBeans 6.0 milestone 10 to see how they do on the world's most mundane JavaServer Faces application: the login example from Core JSF.

Installation

Installing NetBeans was a breeze. You have the choice between Basic, Standard, and Full. I downloaded Standard and ran the installer. It installed NetBeans and GlassFish, and I was all set to start a new JSF project.

Installing Eclipse is easy if you know what to do: Grab the "Eclipse IDE for Java EE Developers". (I first downloaded the "Eclipse IDE for Java Developers", hoping I could select the JSF add-on, and have the plugin manager resolve the dependencies. I never even found the JSF addons in the morass of plugins, most of which had names that made no sense to me.)

After installing Eclipse, I hooked it up with GlassFish, following these simple directions.

Unfortunately, you are still not quite ready to use JSF. You have to carefully follow the instructions in the excellent blog by Jeroen van Wilgenburg and set up JSF libraries. Jeroen uses myfaces; for GlassFish you need to include javaee.jar and jsf-impl.jar.

???

Maybe the GlassFish plugin could take care of that?

You will also need to change the Eclipse startup configuration to give it more memory, as described here. Otherwise, you will get frequent crashes such as this one:

???

Adding a JSF Page

This should not be rocket science, right? Right-click on the "pages" node in the project and select "Add JSF page".

Unfortunately, it is not so easy. In Eclipse, you add a JSP page:

???

Then you get a wizard whose second page looks like this:

???

According to the online help, you are now supposed to make a JSP page and add the taglib or namespace declarations. WTP? Does Eclipse hate JSF programmers? Why not include a template "New JSF file"? Fortunately, it is an easy matter to make such a template.

With NetBeans, you get a seemingly useful "Visual Web JSF Page". Unfortunately, as you'll see later, that choice is problematic. Instead, choose JSP.

???

Now you get this dialog:

???

Again, there is no option for a JSF file, and there isn't any apparent mechanism to provide a template. You have to make a JSP file and then paste in the taglib or namespace declarations. NetBeans really hates JSF programmers.

EL Autocompletion

Defining a managed bean worked in both IDEs. Annoyance in NetBeans: I can't set the EL name for the bean in the dialog. Annoyance in Eclipse: When I change the name of the bean class, it doesn't automatically update faces-config. Both IDEs can autocomplete the bean name and its properties as you would expect.

In Eclipse, I can use the faces-config editor to add a resource bundle, and I get autocompletion. NetBeans doesn't seem to have any support for resource bundles. When I manually add the resource bundle into faces-config.xml, NetBeans still won't autocomplete. NetBeans really needs to fix that before the final release.

???

Navigation Rules

Both Eclipse and NetBeans have serviceable visual editors for adding navigation rules. Here is the Eclipse editor. Note the cheat sheet on the right. Without that, I would not have been able to work the editor since right-clicking on the arrow brings up a completely useless context menu.

???

Visual Page Editing

It took me a while to discover this feature in Eclipse. You need to right-click on the JSF page in the explorer pane and then select "Web Page Editor".

???

You get a serviceable editor that lets you drag components into a h:panelGrid or h:dataTable.

???

I could not see how to visually edit an existing JSF page in NetBeans. You can start a new "Visual JSF Page", but that is an entirely different animal. You essentially get the editor from Java Studio Creator. If you like Creator, then this is a good thing. You now have a way of linking your Creator pages to your Java backend code in a single environment.

But I don't like Creator, for two reasons.

  • The widget set seems fairly nice but it is not standard. I'd like to learn one standard widget set. Can you imagine how much worse the lot of the Swing programmer would be if they had to learn a different component set for each project?
  • I am forced into a specific programming model, with a backing bean per page and the use of binding. This may feel comfortable to Visual Basic programmers, but to me it is not in the spirit of JSF. I prefer to share a bean among related pages, and I prefer to use the value attribute to link form values to beans.

I fussed with the code, ripping out the Creator code and adding plain JSF code. That just confused the design mode. At least in this milestone, it seems as if the visual page editor in NetBeans is limited to Creator pages.

I didn't try adding a third-party component to the palette. There just isn't enough oomph in the JSF standard to support that.

Conclusion

Both Eclipse and NetBeans are supporting the basics, in particular autocompletion of JSF tags and EL expressions. For the purpose of JSF development, neither IDE seemed particularly slick to me; procedures for achieving common tasks seemed haphazard, unflexible, or unintuitive. At this point, I prefer Eclipse, but not by a huge margin. To gain parity, NetBeans needs to support resource bundles, make a wizard for adding genuine JSF (and not just JSP) pages, and rig its visual editor to handle non-Creator pages.

???Soapbox: In 2001 (!), JSF was envisioned as "Swing for the Web", a standard framework for delivering high quality web applications. I remember asking Amy Fowler at the 2002 Java One whether it will include professionally designed components similar to those in Swing, and she said "of course". Unfortunately, in 2007, we still don't have a standard set of widgets that is needed in practice, such as tabs, breadcrumbs, header/footer, menus, etc. etc. We also have no standard way of plugging third-party component sets into visual tools. JSR 314 promises JSF 2.0 by April 2008, with a huge laundry list of desirable features. A standard widget set is not among them.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Great article. We have such a long way to go!

    Posted by: benloud on July 03, 2007 at 08:03 PM

  • While I agree that out-of-the-box JSF support could be better, I think Netbeans has very good support for JSF. I personally only use Eclipse for Python development so I am not familiar with it's JSF capabilities. However, if you choose to create a web application based upon the JSF framework in Netbeans, then it automatically sets up the application to run using JSF. I think that the setup is the biggest hurdle when people are trying to use a web framework. If people must include a tag library reference at the top of each page then it is a trivial task compared to the setup of the application.

    Also, Netbeans has some great plug-ins which facilitate the ease of JSF development. Specifically, the Facelets and JBoss Seam plug-ins create JSF pages in the XHTML format including all JSF-related tag references.

    You've written a good article here, and the comparisons between the IDEs are great. However, I do think that some of Netbeans' JSF features are nice and it is slick in my opinion. By the way, keep up the good work...your JSF book was one that helped to get me started on the framework back in it's infancy.

    Posted by: javajuneau001 on July 05, 2007 at 03:45 AM

  • As Eclipse based solution goes: There is
    Exadel Studio Pro(free, soon to be open source) and BEA Workshop™ for JSF(commercial) to name a few. They build on top of WTP and provide custom support for JSF.

    IMHO: There are more agile web frameworks out there such as Wicket and GWT that don't require such heavy IDEs and come closer to "Swing for the Web" than JSF. Ofcorse this is just my opinion. It is always good to have a variety of different approaches.

    Posted by: avrecko on July 05, 2007 at 06:25 AM

  • I agree that the lack of complete set of modern, quality components out of the box with JSF is a serious, long standing issue. OTOH

    https://woodstock.dev.java.net/

    seems to be addressing this, and, best of all seems to be fairly well connected to netbeans and its GUI builder. I am advised that it looks good when rendered, but I see that it doesn't have all of the widgets yet.

    Anybody tried this?

    Posted by: ga427 on July 05, 2007 at 09:17 AM


  • @javajuneau001: I don't want to imply that all JSF features of NetBeans are bad. I simply want to point out that NetBeans needs a few tweaks to support developers who want to write a plain Jane JSF app.

    @avrecko: Wicket and GWT (and a dozen other Java web frameworks) have their advantages. But JSF is the Java EE standard, and NetBeans is on record as being committed to supporting standard Java. I hope they will support standard JSF at least as well as the nonstandard Creator components (and at least as well as Eclipse :-)).

    @ga427: Thanks for the Woodstock reference. I agree that there are good JSF component sets. Apache Trinidad (née ADF Faces) is another fine example. Competition is all good and well, but at some point we should pick the best practices and roll them into a standard. After all, that is how JSF came into being in the first place.

    Posted by: cayhorstmann on July 05, 2007 at 11:29 AM

  • nice article! Am still trying to run europa on my win XP sp2. Sun JVM6up2 keeps crashing. Though eclipse tries loading, crashies eventually. Any body experienced similar problem running eclipse 3.3?
    Any help would be greatly appreciated.

    Posted by: deenick007 on July 06, 2007 at 07:45 AM

  • nice but i think we should consider oracle JDeveloper which provide nice support for declarative JSF developement

    Posted by: pravingole on July 26, 2007 at 04:26 AM

  • I have to agree with pravin. JDeveloper is truly miles ahead in a lot of areas in comparison with both the above mentioned editors.

    Posted by: suryad on July 31, 2007 at 06:03 AM

  • Although Netbeans6 M10 is not yet a production release, running it on a laptop with core 2 duo and 1gb ram and Windows Vista Business edition is painfully slow. Some of its features could do with some polishing. On the plus side you don't have to go downloading hordes of extras and try to get them to work together, unlike Eclipse. I therefore find it easier to use. Having said that I use Eclipse at work as I don't have to do JSF development as its far faster for general Java development.

    Posted by: aschulew on August 19, 2007 at 01:40 PM

  • The huge sell of this article is the being able to see what your jsp page looks like visually and edit it visually, instead of staring at and editing a bunch of html.

    Posted by: firefight on November 01, 2007 at 10:20 AM

  • Thank god, there is the alternative project wingS, that has a rich set of "professionally designed components similar to those in Swing" ;-)

    Posted by: hengels on November 02, 2007 at 03:23 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds