Developer Woes

September 19, 2007

Yesterday was one of the days were everything begins promising and after hours and hours it ends in a developer desaster. Although I tried 13 hours to get a Liferay portlet with hibernate, icefaces and myfaces to work it did not work. After all these hours I think there might be a reason why Liferay distributes its icefaces sample portlet with the SUN Reference Implementation of Java Server Faces and not Apache’s MyFaces.

It all began yesterday morning when I accessed Alfresco which was deployed as a portlet within Liferay via the WSRP Api. Strange to say this worked out of the box which made me very happy and maybe also brought me the motivation to go on more than 12 hours from that point.

In the afternoon I simply needed a JSF Tag which can iterate over a List and display its content. After some googling I found out that there is no JSF tag which supports this function. So I decided to write my own JSF component with the help of some examples with similar functionality. Unfortunately this did not work out of the box and after some more googling I found out that Apache MyFaces provides a tag called dataList which exactly was what I needed. So why don’t switch to icefaces with MyFaces? This combination would have been phenomenal as there could have been a solution to also get tomahawk working and to have a really big choice of prebuilt JSF components then. Well it wouldn’t work. After many hours of experimenting it boilt down to one Exception within one of the Liferay portlet JSF helper classes. It looked like this helper class could not deal with the ICEFaces workaround of handling the FacesContext. After some more googling I found out that ICEFaces within portlets is not considered production ready until version 1.7 of ICEFaces and so I switched to MyFaces and Tomahawk instead of ICEFaces for this portlet completely. AJAX components are not that useful in this portlet context and so the switch is acceptable whereas the big amount of wasted time is not :-).

But that was yesterday. The Myfaces, Facelets example is working now within Liferay and hopefully the accessing of Alfresco will too.

Have a nice day

Phillip

8 Responses to “Developer Woes”

  1. Neil Griffin Says:

    I’m the author of the sample-icefaces-sun-portlet distributed by Liferay. I actually have a MyFaces RI counterpart, but it hasn’t been committed to SVN yet. That is they only reason why Liferay has distributed only the Sun RI to date.

    Now, regarding MyFaces Tomahawk, IMHO it is not a good match with portlets in general. Tomahawk relies on a servlet filter, which is technologically incompatible with JSR-168 portlets. There is a Tomahawk bridge project that attempts to fill this gap, but Liferay customers have had mixed results with it. Again, this is not a Liferay problem, but a problem with Tomahawk and portlets in general.

    You’re right — ICEfaces 1.6.0 has enough portlet support to get you developing with ICEfaces, but is not ready for production deployments. ICEfaces 1.6.1 has some patches that help in this regard, but ICEfaces 1.7 will be the release that supports production releases of ICEfaces portlets.

    The engineers at ICEsoft have worked hard to make much (if not all) of Tomahawk work alongside ICEfaces components on the same page, but because of the servlet filter dependency I would not recommend this combination in portlets.

    Regards,

    Neil Griffin

  2. phillme Says:

    Hi Neil.
    That sounds interesting. Do you think it would be possible to send the icefaces-myfaces-portlet to me via email or can I download the latest version already on this page http://support.liferay.com/browse/LEP-3057?

    I would transform the whole portlet into a maven build and add hibernate JPA capabilities. Maybe that could be useful to you, too?

    Regards,
    Phillip Merensky

  3. phillme Says:

    I looked at your example portlet from the above link in detail and found out that you are using myfaces 1.1.2. I tried to get a portlet with icefaces 1.6.0 and myfaces 1.1.5 working. Maybe that is the reason why it did not work on my side. Never mind! I do not need it at the moment anyway.

    Thanks for your comment though
    Phillip

  4. Neil Griffin Says:

    Phillip,

    I just committed the code for the sample-icefaces-myfaces-portlet to the plugins trunk.

    It is compatible with Liferay 4.3.2, and will likely be formally released as an “Official Liferay Plugin” soon when Liferay 4.3.3 is released.

    The MyFaces version is essentially the same as the Sun version. The only real change is that the Sun RI (jsf-api.jar, jsf-impl.jar) were swapped out for the MyFaces ones (myfaces-api.jar, myfaces-impl.jar). In addition, the Sun-RI-specific entries from web.xml were removed.

    The version of ICEfaces bundled with this portlet is 1.6.0, and the version of MyFaces is 1.1.5, so it should meet the requirements you specify above.

    Thank you for offering to re-package as a Maven project, but Liferay is encouraging the use of the new “Plugins SDK” for development of portlets. The SDK is based on Ant of course, and I don’t think it will move to Maven any time soon.

    The new Liferay website provides a way for you to upload your own plugins. This sounds like a perfect place for you to put a Hibernate powered portlet like you offered above.

    Regards,

    Neil

  5. Neil Griffin Says:

    BTW, I also committed an ICEfaces-Facelets portlet to the plugins trunk today. It uses the Sun RI, but can be modified for use with the MyFaces RI using the same procedures I mentioned earlier.

    Neil

  6. phillme Says:

    It is really strange that you got it working without hassle. I did get really strange Exceptions. Potentially I mixed up some required libraries of MyFaces with the Liferay ones.
    Anyway I am glad that there will be an official version soon. If I have some spare time the next days I will upload my hibernate version.

    Thanks for your help and feedback
    Phillip

  7. Alex Says:

    Hi Phillip,

    can you please send me your sample portlet project using jsf, jpa and maven for build? I’m new to portlet development, so any help is much appreciated. Thanks!

    Regards,
    Alex

  8. phillme Says:

    Sorry for the late reply. Notifications of comments somehow did not work. I sent you the zipped eclipse project as an attachment. If you need further examples you can look into the sourceforge.net subversion of this project.

    Regards,
    Phillip


Leave a comment