Thursday, August 25, 2005

facelets and MyFaces living together in harmony

So I discovered in the end it was a lack of configuration that was causing the issues in my port from JSF RI with JSPs to MyFaces with facelets.

The facelet was not recognizing the MyFaces extension components because they were not registered, something that's automatic in the JSP environment.
It turns out you need an entry in the web.xml file and a file to define the extra components. Definitely not something you can deduce on your own!

I ended up enhancing this page to give those that follow a better chance of success!

Now I can get on with the task at hand! ;)

Wednesday, August 24, 2005

Looking for a culprit: facelets or MyFaces?

I guess this is what you get when you start playing with new technology before the paint's dry.
I have a system using JSP & Sun's JSF RI.

So now I decide that I can't live with this combo any more, and so I decide to change to Facelets and Apache MyFaces.

Every thing is going along swimmingly until I actually put a complex JSF component into the mix. This is the Newspaper Table from the MyFaces Tomahawk suite.
Now this was working just fine in a previous setup, but the new config of the system under MyFaces in the facelets view template doesn't recognise (or can't resolve) an instance variable in the component.

What to do? Well can I find anything on this issue? Google turns up virtually nothing.

Is it MyFaces? (I'm sure it's MyFaces creating the error, but this is a MyFaces JSF control. So I try a standard DataTable - no problems there, and the Newspaper Table is supposed to be derived from the DataTable.)
Or facelets? (Maybe facelets isn't initializing the component properly?)
(Or an unhappy combo of the two?)

No chance. Stumped. Time to work around again... :(

Ah... facelets

Well, thanks to a comment on one of my posts, I've now been reminded to blog again.
The No-Fluff Java Symposium is coming around again, and I have what? Four posts to my name?

Since last year, I have worked with JSF somewhat and have had pretty good success with it.
There are some really annoying things about using it with JSPs, especially if you just want to stuff some HTML markup into the mix.
In some cases (usually when inside another JSF parent component - pretty much a given when using Tiles) the HTML gets rendered by the JSP container ahead of the JSF tags - and that's definitely not what I ordered!

Enter facelets, a great new templating system for JSF which completely removes the JSP engine out of the picture. You can define a standard HTML page and plug it into your page template, Tapestry-style (no need for Tiles) and have it rendered perfectly, with no need to restart the web server.

Now that's much better. :)