private static void appendScriptToChain(StringBuilder builder, String script) {

    if ((script == null) || (script.length() == 0)) {
      return;
    }

    if (builder.charAt(builder.length() - 1) != ',') builder.append(',');

    appendQuotedValue(builder, script);
  }
  public static void appendProperty(
      StringBuilder builder, String name, Object value, boolean quoteValue) {

    if ((null == name) || (name.length() == 0)) throw new IllegalArgumentException();

    char lastChar = builder.charAt(builder.length() - 1);
    if ((lastChar != ',') && (lastChar != '{')) builder.append(',');

    appendQuotedValue(builder, name);
    builder.append(":");

    if (value == null) {
      builder.append("''");
    } else if (quoteValue) {
      appendQuotedValue(builder, value.toString());
    } else {
      builder.append(value.toString());
    }
  }
  public static String findClientIds(String ids, UIComponent component, FacesContext context)
      throws IOException {
    if (ids == null) return null;

    StringBuilder clientIds = new StringBuilder();
    String[] idlist = ids.split("[\\s]");
    for (String id : idlist) {
      if (!id.startsWith("@")) {
        UIComponent found = component.findComponent(id);
        if (found != null) {
          if (clientIds.length() > 0) clientIds.append(" ");
          clientIds.append(found.getClientId(context));
        } else {
          throw new IOException("Cannot find id " + id + " within components NamingContainer");
        }
      }
    }

    return clientIds.toString();
  }