users@jsf-extensions.java.net

Error executing simple AJAX example

From: Scott <jackett_dad_at_yahoo.com>
Date: Wed, 8 Aug 2007 06:51:01 -0700 (PDT)

I'm brand new to JSF and AJAX, but I've got a pretty good grasp on the basics. Before I describe the problem, here is a rundown of my environment: Windows XP Pro IntelliJ running Java JDK 1.5 Tomcat 5.5 JSF 1.2 jsf-extensions 0.1 rc 2 Facelets 1.0.14 (hopefully this is beside the point) I created a simple bean that contains a list of fruits and keeps track of which one is selected. On my page I put them in a drop down box, and once a fruit is selected, a text area changes to reflect the selected fruit name (I lifted this from an example). Here is the whole xhtml page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:jsfExt="http://java.sun.com/jsf/extensions/dynafaces" xmlns:p="http://www.proformacorp.com/jsf"> <f:loadBundle var="bundle" basename="i18n.messages"/> <ui:composition template="/jsfadmin/pages/layout/layout.xhtml"> <ui:define name="title"><h:outputText value="#{bundle.rules_title}"/></ui:define> <ui:define name="content"> <div id='pfmaincontent' style="vertical-align: top; width:100%;"> <h1>Fruit selection AJAX Demo</h1> <h:form prependId="false" id="form"> <table cellpadding="4"> <jsfExt:ajaxZone> <tr> <td><h:outputText value="Select a fruit:"/></td> <td> <h:selectOneMenu id="fruit" value="#{fruit.selectedFruit}" valueChangeListener="#{fruit.updateFruit}" onchange="DynaFaces.fireAjaxTransaction(this, { execute: 'fruit', render: 'fruitMessage' });"> <f:selectItems value="#{fruit.fruits}"/> </h:selectOneMenu> </td> </tr> <tr> <td><h:outputText value="Selected:"/></td> <td><h:outputText id="fruitMessage" value="#{fruit.fruitMessage}"/></td> </tr> </jsfExt:ajaxZone> </table> </h:form> </div> </ui:define> </ui:composition> </html> I've got the source code for both JSF and the extensions so I can debug where problems occur. My valueChangeListener is being invoked when I select a fruit, so that part of my AJAX implementation is working. But there is an assertion error happening before a response is rendered. Here is the stack trace: java.lang.AssertionError at com.sun.faces.extensions.avatar.components.PartialTraversalViewRootImpl.encodeChildren(PartialTraversalViewRootImpl.java:330) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886) at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144) at com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.render(PartialTraversalLifecycle.java:107) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685) at java.lang.Thread.run(Thread.java:595) There is a clue in the code that is referenced in the stack trace. Here is that code: public void encodeChildren(FacesContext context) throws IOException { AsyncResponse async = AsyncResponse.getInstance(false); // If this is not an ajax request... if ((async == null) || !async.isAjaxRequest() || async.isRenderAll()) { // Full request or ajax encode All request, operate normally super.encodeChildren(context); } else { // If the context callback was not invoked on any subtrees // and the client did not explicitly request that no // subtrees be rendered... if (!invokeContextCallbackOnSubtrees(context, new PhaseAwareContextCallback(PhaseId.RENDER_RESPONSE)) && !async.isRenderNone()) { assert(false); } } } The assertion is the last line of the method: assert( false ). The comment is the clue, but I don't understand it. Does anyone know what I'm doing wrong? I'm not doing anything specific to render in my valueChangedEvent. I'm just recording the new value so that when the selected fruit text is asked for, I'll know which selection to provide. Again, I'm new, and am probably just missing a crucial step. I'd appreciate if anyone could help me out. Thanks, Scott