Monday, December 03, 2007

All Faces: Java Server Faces, ICEFaces and Facelets in Weblogic Workshop 10.1

It's been a while since I last looked at JSF seriously. The projects I work on day-to-day for the last little while have been Swing and Struts-based.
However, I recently had good reason to delve back in where I left off quite a while ago, and frankly, not much seems to have changed.
Probably the most significant progress is in visual JSF development and AJAX support. We're seeing more developed components and better integration. However, out of the box support for getting up and running with different JSF configurations is still sparse. I feel that things could be a lot smoother with smarter tools support.
JSF is still struggling for dominance over a legacy created by Struts adoption, and an uphill battle against burnt fingers and mis-information about the framework.
I agree with Rick Hightower, that, once configured, you can be more productive and will find things more intuitive than Struts. However, if the goal is to make things as smooth as, say, ASP.NET 2.0, there is still some way to go.

I'm personally rooting for ICEFaces, who have made a fair bit of progress in the year since they Open-Sourced their JSF AJAX framework. ICEFaces is J2EE AJAX 'done right'. The Javascript is managed by the framework, giving a Java programmer the ability to control the state of the UI eficiently and dynamically from the server, using 'AJAX push'.

Having worked with Weblogic 10 for the last little while, I have been impressed with the complete toolset, including the development environment which allows easy integration with Weblogic server on the desktop. Weblogic Workshop is a custom version of Eclipse which includes advanced support for JSF authoring. BEA now includes ICEFaces support within the IDE. However, I ran across a couple of gotcha's which you may be interested in knowing.

ICE Faces support is available as a facet for a Dynamic Web Application in Weblogic Workshop 10.1
Read BEA Dev2Dev introductory article here.
All really good stuff.

Integrating with Facelets involves jumping a couple more hurdles:

BEA support at present is for ICE Faces 1.5.3. It can be added as a Facet to a Dynamic Web Project.
This is not compatible with later versions, and so when integrating facelets, you will have problems if you use the latest downloads from ICE Soft. Make sure you use the icefaces-facelets.jar from the 1.5.3 release if you are using Weblogic Workshop 10.1
The next logical step for BEA would be to include facelets as a project facet dependent on the ICEFaces facet.

Another thing that wasn't immediately apparent to me, is that icefaces-facelets.jar is a complete implementation of facelets, so you don't need to include jsf-facelets.jar in your project. Use icefaces-facelets.jar instead of the default implementation.

Once you get Facelets and ICE Faces configured correctly, you will probably want the IDE to help you with the TAG syntax. However, you will find that you will have little code-completion context help if you use the XHTML format preferred by Facelets.
Eclipse in general is not much help here. MyEclipse has made an effort to correct this oversight. However, all is not lost if you're using Eclipse WTP or Weblogic Workshop.
The trick is to use JSPX format to declare your namespaces. This will introduce code completion for your ICEFaces components, but Facelets tags will still be ignored. You need to get hold of the TLD taglib file for Facelets and place it into WEB-INF/tld.

You can get the Faclets TLD tag-lib file here:
jsf-ui.tld

And here's the final result:

Hope this helps!

4 comments:

ws101frustrated said...

Thank you very much for this post. I'm currently having too much trouble with standard WS10.1 support of JSF 1.1 so I'll give ICE Faces a try.

Anonymous said...

Thanks !
Even after i add jsf-ui.tld to the web-inf in workshop it complains that
"The tei class is not in application class path."

any ideas on how i can get rid of this warning ?

Anonymous said...

http://www.liferay.com/web/ngriffin/blog/-/blogs/best-ide-for-icefaces-portlets-built-with-facelets;jsessionid=6857E376CB786B969E12CF5723A2F0CA?_33_redirect=%2Fweb%2Fngriffin%2Fblog%3Fp_p_id%3D33%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26_33_struts_action%3D%252Fblogs%252Fview

The above link talks about associating xhtml with JSP editor to get content assist working with xhtml files. As with JSPX extenstion, you will still need <jsp:root ....> enclosing tags within xhtml files too.

Just add .xhtml to JSP content types in Eclipse and in file associations go to .xhtml and make JSP Editor the default.

Liferay Testing said...

Mpower consulting is the global leader in providing innovative it business consulting and technology. We offer the best services at a cost effective pricing. Services include software development, liferay, liferay portal and portal implementation.