Package org.ajax4jsf.renderkit

Examples of org.ajax4jsf.renderkit.RendererUtils


   *
   * @see org.ajax4jsf.context.AjaxContext#addAreasToProcessFromComponent(javax.faces.component.UIComponent)
   */
  @Override
  public void addAreasToProcessFromComponent(FacesContext context, UIComponent component) {
    RendererUtils rendererUtils = RendererUtils.getInstance();
   
    Set<String> areasToProcess = AjaxRendererUtils.getAjaxAreasToProcess(component);
    if (areasToProcess != null) {
      Set<String> convertedAreaIds = new HashSet<String>();

      for (String areaId : areasToProcess) {
        UIComponent areaComponent = rendererUtils.findComponentFor(component, areaId);
        if (areaComponent != null) {
          convertedAreaIds.add(areaComponent.getClientId(context));
        } else {
          convertedAreaIds.add(areaId);
        }
View Full Code Here


   * @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

 
  @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

  private static final String[] OPTIONS_ATTRIBUTES_LIST = { "showConnectingLines", "toggleOnClick",
    "disableKeyboardNavigation", "rightClickSelection"};
 
  public String getOptions(FacesContext context, UITree tree) {
    Map<String, Object> attributes = tree.getAttributes();
    RendererUtils utils = getUtils();
   
    Map<String, Object> options = new HashMap<String, Object>();
    for (String optionAttributeName : OPTIONS_ATTRIBUTES_LIST) {
      Object value = attributes.get(optionAttributeName);
     
      if (utils.shouldRenderAttribute(value)) {
        options.put(optionAttributeName, value);
      }
    }
   
    return ScriptUtils.toScript(options);
View Full Code Here

    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

    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

            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

 
  @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

   * @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

     * @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

TOP

Related Classes of org.ajax4jsf.renderkit.RendererUtils

Copyright © 2018 www.massapicom. 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.