Examples of RendererUtils


Examples of org.ajax4jsf.renderkit.RendererUtils

    return buffer.toString();
    }
   
  protected Map<String, Object> getMenuOptions(UIComponent component) {
        Map<String, Object> options = new HashMap<String, Object>();
    RendererUtils utils = getUtils();
    utils.addToScriptHash(options, "direction", component.getAttributes().get("direction"), "auto");
    utils.addToScriptHash(options, "jointPoint", component.getAttributes().get("jointPoint"), "auto");
    utils.addToScriptHash(options, "verticalOffset", component.getAttributes().get("verticalOffset"), "0");
    utils.addToScriptHash(options, "horizontalOffset", component.getAttributes().get("horizontalOffset"), "0");
    utils.addToScriptHash(options, "oncollapse", component.getAttributes().get("oncollapse"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
    utils.addToScriptHash(options, "onexpand", component.getAttributes().get("onexpand"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
    utils.addToScriptHash(options, "onitemselect", component.getAttributes().get("onitemselect"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
    utils.addToScriptHash(options, "ongroupactivate", component.getAttributes().get("ongroupactivate"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
   
    utils.addToScriptHash(options, "selectItemClass", component.getAttributes().get("selectItemClass"));
    utils.addToScriptHash(options, "itemClass", component.getAttributes().get("itemClass"));
    utils.addToScriptHash(options, "selectItemStyle", component.getAttributes().get("selectItemStyle"));
    utils.addToScriptHash(options, "itemStyle", component.getAttributes().get("itemStyle"));
    return options;
  }
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

            }
        }
        if (itemId != null) {
          scriptObject = new ArrayList<Object>();
            Map<String, Object> options = new HashMap<String, Object>(2);
            RendererUtils utils = getUtils();
            scriptObject.add(itemId);
           
      utils.addToScriptHash(options, "onmouseout", kid.getAttributes().get("onmouseout"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
      utils.addToScriptHash(options, "onmouseover", kid.getAttributes().get("onmouseover"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
      utils.addToScriptHash(options, "onselect", kid.getAttributes().get("onselect"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
      utils.addToScriptHash(options, "closeOnClick", closeOnClick, "true");
      utils.addToScriptHash(options, "flagGroup", flagGroup);
      utils.addToScriptHash(options, "styleClass", kid.getAttributes().get("styleClass"));
      utils.addToScriptHash(options, "style", kid.getAttributes().get("style"));
      utils.addToScriptHash(options, "disabledItemClass", kid.getAttributes().get("disabledItemClass"));
      utils.addToScriptHash(options, "disabledItemStyle", kid.getAttributes().get("disabledItemStyle"));
      utils.addToScriptHash(options, "labelClass", kid.getAttributes().get("labelClass"));
      utils.addToScriptHash(options, "selectedLabelClass", kid.getAttributes().get("selectedLabelClass"));
      utils.addToScriptHash(options, "disabledLabelClass", kid.getAttributes().get("disabledLabelClass"));
      utils.addToScriptHash(options, "selectClass", kid.getAttributes().get("selectClass"));
      utils.addToScriptHash(options, "selectStyle", kid.getAttributes().get("selectStyle"));
      utils.addToScriptHash(options, "iconClass", kid.getAttributes().get("iconClass"));
      utils.addToScriptHash(options, "disabled", disabled);
      if (!options.isEmpty()) {
        scriptObject.add(options);
      }
        }
       
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

            resource = getResource("images/spacer.gif").getUri(
                    context, menuItem);
        }
        variables.setVariable("icon", resource);
       
      RendererUtils rendererUtils = getUtils();

        if (menuItem.isDisabled()) {
            variables.setVariable("iconDisabledClasses",
                    "rich-menu-item-icon-disabled");
        } else {
            Map<String, Object> menuItemAttributes = menuItem.getAttributes();

            // create attributes string for item without parent
            Map<String, Object> attrMap = new HashMap<String, Object>(3);
      if (!isNestedInMenu(menuItem)) {
                rendererUtils.addToScriptHash(attrMap, "styleClass", menuItemAttributes.get(HTML.STYLE_CLASS_ATTR),
                  null, ScriptHashVariableWrapper.DEFAULT);

                rendererUtils.addToScriptHash(attrMap, "onselect", menuItemAttributes.get(HTML.onselect_ATTRIBUTE),
                      null, ScriptHashVariableWrapper.EVENT_HANDLER);
            }

            //-----------------------------------
            StringBuilder scriptValue = new StringBuilder();
            String mode = resolveSubmitMode(menuItem);
           
            if (MenuComponent.MODE_AJAX.equalsIgnoreCase(mode)) {
              scriptValue.append("RichFaces.Menu.updateItem(event,this");
             
              if (!attrMap.isEmpty()) {
                scriptValue.append(',');
                  scriptValue.append(ScriptUtils.toScript(attrMap));
              }

              scriptValue.append(");");
              String event = null;
              Object onclick = menuItemAttributes.get(HTML.onclick_ATTRIBUTE);
              if(onclick != null && onclick.toString().length()>0){
                event = HTML.onclick_ATTRIBUTE;
              }else{
                Object onselect = menuItemAttributes.get(HTML.onselect_ATTRIBUTE);
                if(onselect != null && onselect.toString().length()>0){
                  event = HTML.onselect_ATTRIBUTE;
                }
              }
              scriptValue.append(AjaxRendererUtils.buildOnEvent(
                        menuItem, context, event, true).toString());
              menuItemAttributes.put(HTML.onselect_ATTRIBUTE, null);
            } else if (MenuComponent.MODE_SERVER.equalsIgnoreCase(mode)) {
             
            /*
             String id = menuItem.getClientId(context);
      scriptValue.append("var form=A4J.findForm(this);");
      scriptValue.append("var params={");
      scriptValue.append(ScriptUtils.toScript(id + ":hidden"));
      scriptValue.append(":");
      scriptValue.append(ScriptUtils.toScript(id));
      scriptValue.append("};");
     
      List params = encodeParams(context, menuItem);
      if(!params.isEmpty()){
        for (Iterator iterator = params.iterator(); iterator.hasNext();) {
          scriptValue.append(iterator.next());
        }
      }
     
      scriptValue.append("Richfaces.jsFormSubmit(");
      scriptValue.append(ScriptUtils.toScript(id)).append(",");
     
      scriptValue.append("form.id").append(",");
          Object target = menuItem.getAttributes().get("target");
                
          if (null != target) {
         scriptValue.append(ScriptUtils.toScript(target));
       } else {
        scriptValue.append("''");
      }
         
          scriptValue.append(",");
          scriptValue.append("params);return false;");
          */
              Object onclick = menuItemAttributes.get(HTML.onclick_ATTRIBUTE);
              if(onclick != null && onclick.toString().length()>0){
                scriptValue.append(onclick.toString());
                scriptValue.append(";");
              }
              scriptValue.append("RichFaces.Menu.submitForm(event,this");
             
              Map<String, Object> scriptOptionsMap = new HashMap<String, Object>(5);
              rendererUtils.addToScriptHash(scriptOptionsMap, "a", attrMap, null, ScriptHashVariableWrapper.DEFAULT);
             
              Map<String, Object> paramsMap = getParamsAsMap(context, menuItem);
              rendererUtils.addToScriptHash(scriptOptionsMap, "p", paramsMap, null, ScriptHashVariableWrapper.DEFAULT);

              String target = (String) menuItemAttributes.get("target");
              rendererUtils.addToScriptHash(scriptOptionsMap, "t", target, null, ScriptHashVariableWrapper.DEFAULT);

              if (!scriptOptionsMap.isEmpty()) {
                scriptValue.append(',');
                scriptValue.append(ScriptUtils.toScript(scriptOptionsMap));
              }
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

    protected abstract JSFunction getMenuScriptFunction(FacesContext context, UIComponent component);

    protected String getLayerScript(FacesContext context, UIComponent component) {
    StringBuffer buffer = new StringBuffer();
        Map<String, Object> options = new HashMap<String, Object>();
        RendererUtils utils = getUtils();
    JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
    function.addParameter(component.getClientId(context)+"_menu");
    utils.addToScriptHash(options, "delay", component.getAttributes().get("showDelay"), "300");
    utils.addToScriptHash(options, "hideDelay", component.getAttributes().get("hideDelay"), "300");
    utils.addToScriptHash(options, "selectedClass", component.getAttributes().get("selectedLabelClass"));
        if (!options.isEmpty()) {
          function.addParameter(options);
    }
    function.appendScript(buffer);
    if (component instanceof UIMenuGroup) {
      options = new HashMap<String, Object>();
      buffer.append(".");
      JSFunction subMenuFunction = new JSFunction("asSubMenu");
      subMenuFunction.addParameter(component.getParent().getClientId(context)+"_menu");
      subMenuFunction.addParameter(component.getClientId(context));
      utils.addToScriptHash(options, "evtName", component.getAttributes().get("event"), "onmouseover");
      utils.addToScriptHash(options, "direction", component.getAttributes().get("direction"), "auto");
      utils.addToScriptHash(options, "onopen", component.getAttributes().get("onopen"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
      utils.addToScriptHash(options, "onclose", component.getAttributes().get("onclose"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
        if (!options.isEmpty()) {
          subMenuFunction.addParameter(options);
        }
      subMenuFunction.appendScript(buffer);
    } else {
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

 
  @Override
  protected void encodeRowEvents(FacesContext context, UIDataAdaptor table)
      throws IOException {
    super.encodeRowEvents(context, table);
    RendererUtils utils2 = getUtils();
    utils2.encodeAttribute(context, table, "onRowContextMenu", "oncontextmenu" );
   
  }
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

    return shiftedLabels;
  }

  protected Map<String, Object> getSymbolsMap(FacesContext facesContext, UICalendar calendar) {
    Map<String, Object> map = new LinkedHashMap<String, Object>();
    RendererUtils utils = getUtils();
    utils.addToScriptHash(map, WEEK_DAY_LABELS, ComponentUtil.asArray(calendar.getWeekDayLabels()));
    utils.addToScriptHash(map, WEEK_DAY_LABELS_SHORT, ComponentUtil.asArray(calendar.getWeekDayLabelsShort()));
    utils.addToScriptHash(map, MONTH_LABELS, ComponentUtil.asArray(calendar.getMonthLabels()));
    utils.addToScriptHash(map, MONTH_LABELS_SHORT, ComponentUtil.asArray(calendar.getMonthLabelsShort()));
    int day = calendar.getFirstWeekDay();
    if (0 <= day && day <= 6) {
      utils.addToScriptHash(map, "firstWeekDay", day);     
    } else if (day != Integer.MIN_VALUE) {
      facesContext.getExternalContext()
        .log(day + " value of firstWeekDay attribute is not a legal one for component: "
            + MessageUtil.getLabel(facesContext, calendar) + ". Default value was applied.");
    }
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

    Map<String, Object> labels = new HashMap<String, Object>();
   
    if (null != bundle1 || null != bundle2) {
      // TODO: make one function call
      String[] names = {"apply", "today", "clean", "cancel", "ok", "close"};
      RendererUtils utils= getUtils();
     
      for (String name : names) {
          String label = null;
          String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() + "_LABEL";
         
          if (bundle1 != null) {
            try {
              label = bundle1.getString(bundleKey);
            } catch (MissingResourceException mre) {
            // Current key was not found, ignore this exception;
            }
          }
         
          // Current key wasn't found in application bundle, use CALENDAR_BUNDLE,
          // if it is not null
          if((label == null) && (bundle2 != null)) {
            try {
              label = bundle2.getString(bundleKey);
            } catch (MissingResourceException mre) {
            // Current key was not found, ignore this exception;
            }
          }
          utils.addToScriptHash(labels, name, label);      
      }
    }
    return labels;
  }
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

   * @param table
   * @throws IOException
   */
  protected void encodeRowEvents(FacesContext context, UIDataAdaptor table)
      throws IOException {
    RendererUtils utils2 = getUtils();
    for (int i = 0; i < TABLE_EVENT_ATTRS.length; i++) {
        String[] attrs = TABLE_EVENT_ATTRS[i];
      utils2.encodeAttribute(context, table, attrs[1], attrs[0]);       
    }
  }
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

    UIProgressBar progressBar = (UIProgressBar) component;
    ComponentVariables variables = ComponentsVariableResolver.getVariables(
        this, component);
    StringBuffer script = new StringBuffer();
        Map<String, Object> options = new HashMap<String, Object>();
        RendererUtils utils = getUtils();

    String clientId = component.getClientId(context);
   
        utils.addToScriptHash(options, "mode", component.getAttributes().get("mode"), "ajax");
        utils.addToScriptHash(options, "minValue", component.getAttributes().get("minValue"), "0");
        utils.addToScriptHash(options, "maxValue", component.getAttributes().get("maxValue"), "100");
        utils.addToScriptHash(options, "context", getContext(component));
    StringBuffer markup = getMarkup(context, component);
        utils.addToScriptHash(options, "markup", markup != null ? new JSLiteral(markup.toString()) : null);
        utils.addToScriptHash(options, "options", buildAjaxOptions(clientId, progressBar, context));
        utils.addToScriptHash(options, "progressVar", component.getAttributes().get("progressVar"));
        utils.addToScriptHash(options, "state", state, "initialState");
        utils.addToScriptHash(options, "value", variables.getVariable("value"));

    script.append("new ProgressBar('").append(clientId).append("'");
        if (!options.isEmpty()) {
          script.append(",").append(ScriptUtils.toScript(options));
    }       
View Full Code Here

Examples of org.ajax4jsf.renderkit.RendererUtils

  }

  @Override
  protected Map<String, Object> getMenuOptions(UIComponent component) {
    Map<String, Object> options = super.getMenuOptions(component);
    RendererUtils utils = getUtils();
    utils.addToScriptHash(options, "onEvt", component.getAttributes().get("event"), "onmouseover");
    utils.addToScriptHash(options, "disabled", component.getAttributes().get("disabled"));
    return options;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.