Ajax ajax = (Ajax) action;
if (ajax.isDisabled()) {
return null;
}
ScriptBuilder buf = new ScriptBuilder();
String onevent = ajax.getOnevent();
if (onevent != null) {
buf.append(onevent);
buf.semicolon();
}
final String id = ajax.getId();
AjaxInitializer ajaxInitializer = new AjaxInitializer() {
@Override
protected Object getAjaxComponentParam(FacesContext context, OUICommand ajax) {
return new RawScript("O$._actionIds['" + id + "']");
}
@Override
protected Object getExecuteParam(FacesContext context, OUICommand ajax, Iterable<String> execute) {
return new RawScript("O$._executeIds['" + id + "']");
}
};
JSONArray renderArray = ajaxInitializer.getRenderArray(context, (OUICommand) action, ajax.getRender());
String idExpression = "O$._renderIds['" + id + "']";
Script render = new RawScript("(" + idExpression + " ? " + idExpression + " : " + renderArray.toString() + ")");
buf.functionCall("O$._ajaxReload",
render,
ajaxInitializer.getAjaxParams(context, ajax)).semicolon();
return buf.toString();
}