) throws IOException {
RenderKitFactory factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
RenderKit renderKit = factory.getRenderKit(context, context.getViewRoot().getRenderKitId());
Renderer renderer = renderKit.getRenderer(component.getFamily(), component.getRendererType());
JSONObject customJSONParam = AjaxUtil.getCustomJSONParam(context, request);
AjaxPortionRenderer ajaxComponentRenderer = (AjaxPortionRenderer) renderer;
for (String nextId : updatePortions) {
StringBuilder portionOutput;
JSONObject responseData;
StringWriter stringWriter = new StringWriter();
ResponseWriter originalWriter = substituteResponseWriter(context, request, stringWriter);
try {
responseData = ajaxComponentRenderer.encodeAjaxPortion(context, component, nextId, customJSONParam);
portionOutput = new StringBuilder(stringWriter.toString());
} catch (JSONException e) {
throw new RuntimeException(e);
} finally {
restoreWriter(context, originalWriter);