@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
if (!component.isRendered()) return;
super.encodeEnd(context, component);
CompositeFilter compositeFilter = (CompositeFilter) component;
ResponseWriter writer = context.getResponseWriter();
writer.endElement("div");
String _for = compositeFilter.getFor();
if (_for != null) {
UICommand applyButton = Components.getOrCreateFacet(context, compositeFilter, HtmlCommandButton.COMPONENT_TYPE, "applyButton", UICommand.class);
if (applyButton.getValue() == null)
applyButton.setValue("Apply");
applyButton.getAttributes().put("onclick", new ScriptBuilder().O$(compositeFilter).dot().functionCall("apply").append(";return false;").toString());
applyButton.encodeAll(context);
String ajaxForApplyId = Components.generateIdWithSuffix(compositeFilter, "ajaxForApply");
Ajax ajaxForApply = (Ajax) compositeFilter.findComponent(ajaxForApplyId);
if (ajaxForApply == null) {
ajaxForApply = new Ajax();
ajaxForApply.setId(ajaxForApplyId);
ajaxForApply.setExecute(new ArrayList<String>(Collections.singletonList(":" + compositeFilter.getClientId(context))));
ajaxForApply.setRender(new ArrayList<String>(Collections.singletonList(_for)));
ajaxForApply.setStandalone(true);
compositeFilter.getChildren().add(ajaxForApply);
}
ajaxForApply.encodeAll(context);
}