Code example for Formatter

Methods: formattoString, x 1

        FacesContext context = FacesContext.getCurrentInstance();
        String text = getItemText(context, component, true);
        String handler = getHandler(context, component);
        Formatter fmt = new Formatter();
        fmt.format("%s.addItem(new{", FacesUtils.getJsvar(context, menu));
        encodeItemConfig(fmt, context, component, text);
        if (handler != null)
            fmt.format(",handler:function(){%s}", handler);
    private String getHandler(FacesContext context, UIComponent component) {
        UIForm form = getParentForm(component);
        if (form != null) {
            return super.getOnclickScript(context, form, component, false);
        } else { 
Connect your IDE to all the code out there  Get Codota for Java