webtier@glassfish.java.net

JSF2: using JavaScript to update a component

From: <webtier_at_javadesktop.org>
Date: Tue, 18 Aug 2009 14:15:26 PDT

My components (porting from 1.2) currently use JavaScript/JSON for Ajax updates, so I would like to put something like the following in my renderer's encodeEnd method:

if (context.getPartialViewContext().isAjaxRequest()) {
    PartialResponseWriter w = (...) context.getResponseWriter();
    w.startEval();
    w.write("myUpdateFunction(<some JSON>);");
    w.endEval();
}

By the time my renderer's encodeEnd gets called, someone has (understandably) already called the responseWriter's startUpdate, and I get a nested CDATA error. Closing the update first doesn't work either. What should I be doing to prevent the startUpdate call being made?
[Message sent by forum member 'judys' (judys)]

http://forums.java.net/jive/thread.jspa?messageID=361050