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);