Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Integrating Facelets and Ajax4JSF with MyFaces

I spent a few hours tonight integrating Facelets into an AppFuse-based application. The integrating was fairly easy thanks to the work Thomas Gaudin did back in January. For the most part, it was just a matter of 1) replacing <fmt:message> tags with #{text['key']} tags, 2) replacing the <%@ include file="/common/taglibs.jsp"%> at the top of each page with Facelet's namespace tags and 3) renaming the pages from *.jsp to *.xhtml. The only thing that tripped me up was I thought the "c" namespace was the same as JTLS's URI, but it's actually a whole new URI. Thanks to the Facelets developers for a much-needed fix for JSF.

After I got Facelets integrated and working, I dove into integrating Ajax4JSF. Two hours later and I have the simple repeater demo working. What took so long? I spent an hour staring at (and googling for) the solution to the following error:

PhaseListenerManager.informPhaseListenersBefore(74) | Exception in PhaseListener RENDER_RESPONSE(6) beforePhase.
java.lang.NullPointerException
        at com.sun.facelets.FaceletViewHandler.writeState(FaceletViewHandler.java:759)
        at org.ajax4jsf.framework.renderer.AjaxRendererUtils.writeState(AjaxRendererUtils.java:850)
        at org.ajax4jsf.framework.renderer.AjaxRendererUtils.encodeAreas(AjaxRendererUtils.java:740)
        at org.ajax4jsf.framework.renderer.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:128)
        at org.ajax4jsf.ajax.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:210)

The solution turned out to be removing the FaceletsViewHandler from faces-config.xml:

<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>

Also, it seems the following is required in web.xml:

    <context-param>
        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>

Hopefully this helps others googling for the exception above.

Posted in Java at Oct 12 2006, 02:41:24 AM MDT 9 Comments
Comments:

News to me on the ajax4jsf exception-- I do know that ADF requires the same type of configuration to collaborate with alternate ViewHandlers.

Posted by Jacob Hookom on October 12, 2006 at 04:19 PM MDT #

I was looking at the Ajax4JSF documentation yesterday and noticed in the section on facelets integration: https://ajax4jsf.dev.java.net/nonav/documentation/ajax-documentation/developerGuide.html#d0e2446 the same advice.

Posted by Brad Smith on October 12, 2006 at 05:19 PM MDT #

Matt, When will the integration of JSF+MyFaces+Ajax4JSF in Appfuse be available?

Posted by Jeff on October 12, 2006 at 05:27 PM MDT #

Thanks Brad - I didn't see that - maybe it should be in bold and blinking. ;-)

Jeff - pending approval from my client, hopefully it will go into 1.9.4 and 2.0 in the next couple weeks. I'd like to release 1.9.4 and 2.0 M1 before (or during) the Colorado Software Summit.

Posted by Matt Raible on October 12, 2006 at 05:35 PM MDT #

Cool, Is there anyway I can get an early glimpse of the Facelets, Ajax4JSF & MyFaces stuffs?

Posted by Jeff on October 12, 2006 at 05:41 PM MDT #

Unfortunately, no. I did the work for a client and I'm unable to just "publish" their project to the web for download. Hopefully you understand.

Posted by Matt Raible on October 12, 2006 at 05:49 PM MDT #

Matt, thanks so much for posting this advice. I didn't see it in the documentation either and I read everything I could find. I was on the verge of implementing my own using a servlet. I'm trying to use facelets + jsf + tomahawk + ajax4jsf. Its been a bleeping nightmare getting everything configured and working together. Thanks again Jim

Posted by Jim Robinson on October 26, 2006 at 11:23 PM MDT #

FYI... the latest versions of AppFuse and AppFuse Light both have Facelets and Ajax4JSF integrated.

Posted by Matt Raible on October 26, 2006 at 11:27 PM MDT #

a4j and the combination of technologies mentioned in this post are not ready for enterprise class application. They do fine for demoware or simple form. But, they have a hard time scaling when there are real-world requirements imposed on them (i.e. highly interactive multi-form form-based UI). If developing a large scale form-based app, consider a true Ajax client-side development using something like Yahoo YUI or Goggle's Web Toolkit.

Posted by anonymous on December 28, 2006 at 03:26 PM MST #

Post a Comment:
  • HTML Syntax: Allowed