menuContext.setManagerComponentId(javaScriptWriter .getComponentVarName());
    protected void encodeJsMenuBarItemBegin(UIComponent component,            SelectItem selectItem, boolean hasChild) throws WriterException {        IComponentRenderContext componentContext = javaScriptWriter                .getComponentRenderContext();        String varId = javaScriptWriter.getJavaScriptRenderContext()                .allocateVarName();        MenuContext menuContext = getMenuContext();        menuContext.pushVarId(varId);        String sid = menuContext.getComponentClientId(component); // menuContext.getMenuBarItemId();        javaScriptWriter.write("var ").write(varId).write('=').writeCall(null,                "_declareBarItem").writeString(sid);        int pred = 0;        String txt = selectItem.getLabel();        if (txt != null) {            javaScriptWriter.write(',').writeString(txt);        } else {            pred++;        }        String value = convertItemValue(componentContext, selectItem.getValue());        if (value != null) {            for (; pred > 0; pred--) {                javaScriptWriter.write(',').writeNull();            }            javaScriptWriter.write(',').writeString(value);        } else {            pred++;        }        if (selectItem instanceof IAccessKeySelectItem) {            String key = ((IAccessKeySelectItem) selectItem).getAccessKey();            if (key != null && key.length() > 0) {                for (; pred > 0; pred--) {                    javaScriptWriter.write(',').writeNull();                }                javaScriptWriter.write(',').writeString(key);            } else {                pred++;            }        } else {            pred++;        }        boolean disabled = selectItem.isDisabled();        if (disabled) {            for (; pred > 0; pred--) {                javaScriptWriter.write(',').writeNull();            }            javaScriptWriter.write(',').writeBoolean(true);        } else {            pred++;        }        javaScriptWriter.writeln(");");        if (hasChild == false) {            return;        }        encodeJsMenuPopupBegin(sid);    }