jsWriter.writeln("}");
    private void writeJs(FacesContext facesContext, PrintWriter printWriter,            DataListComponent dgc, String componentId, DataListRenderer dgr,            int rowIndex, ISortedComponent sortedComponents[],            String filterExpression) throws IOException {        DataListRenderer.ListContext listContext = dgr                .createListContext(facesContext, dgc, rowIndex,                        sortedComponents, filterExpression);        CharArrayWriter cw = null;        PrintWriter pw = printWriter;        if (LOG.isTraceEnabled()) {            cw = new CharArrayWriter(2000);            pw = new PrintWriter(cw);        }        Object state = dgc.getAttributes().get(RENDER_CONTEXT_STATE);        IJavaScriptWriter jsWriter = new JavaScriptResponseWriter(facesContext,                pw, dgc, componentId);        String varId = jsWriter.getComponentVarName();        jsWriter.write("var ").write(varId).write('=').writeCall("f_core",                "GetElementById").writeString(componentId).writeln(                ", document);");        jsWriter.write("with(").write(varId).writeln(") {");        jsWriter.writeCall(null, "_startNewPage").writeInt(rowIndex).writeln(                ");");        ResponseWriter oldWriter = facesContext.getResponseWriter();        ResponseStream oldStream = facesContext.getResponseStream();        try {            CharArrayWriter myWriter = new CharArrayWriter(INITIAL_SIZE);            ResponseWriter newWriter = facesContext.getRenderKit()                    .createResponseWriter(myWriter, null, RESPONSE_CHARSET);            facesContext.setResponseWriter(newWriter);            IRenderContext renderContext = HtmlRenderContextImpl                    .restoreRenderContext(facesContext, state, true);            renderContext.pushComponent(facesContext, dgc, componentId);            IComponentWriter writer = renderContext                    .getComponentWriter(facesContext);            dgr.encodeChildren(writer, listContext);            newWriter.flush();            String buffer = myWriter.toString();            int rowCount = 10;            jsWriter.writeCall(null, "_updateNewPage").writeInt(rowCount)                    .write(',').writeString(buffer).writeln(");");        } finally {            if (oldWriter != null) {                facesContext.setResponseWriter(oldWriter);            }            if (oldStream != null) {                facesContext.setResponseStream(oldStream);            }        }        jsWriter.writeln("}");        if (LOG.isTraceEnabled()) {            pw.flush();            LOG.trace(cw.toString());            printWriter.write(cw.toCharArray());        }    }