}
public void encodeChildren(FacesContext context, UIComponent component)
throws IOException {
UIContextMenu menu = (UIContextMenu) component;
ResponseWriter writer = context.getResponseWriter();
String event = menu.getEvent();
if (event == null) {
throw new FacesException("Attribute 'event' is not set for component " + component.getClientId(context));
}
writer.startElement("script", component);
getUtils().writeAttribute(writer, "type", "text/javascript" );
writer.writeText("var contextMenu = new Richfaces.ContextMenu('", null);
writer.writeText(component.getClientId(context), null);
writer.writeText("', ", null);
writer.writeText(menu.getShowDelay() + ", ", null);
writeScriptBody(context, component, true);
writer.writeText(")", null);
writer.writeText(";", null);
writer.writeText(getClientAttachmentOptions(context, menu), null);
if (menu.isDisableDefaultMenu()) {
writer.writeText("Richfaces.disableDefaultHandler('", null);
writer.writeText(event, null);
writer.writeText("');", null);
}