public void command_removeSelMetric() {
    FacesContext context = FacesContext.getCurrentInstance();
    Object o1 = context.getExternalContext().getRequestParameterMap().get("removeMetricInternalID");
    Object o2 = context.getExternalContext().getRequestParameterMap().get("table");

    if ((o1 != null) && (o2 != null)) {
      String removeMetricID = o1.toString();
      String fromTable = o2.toString();

      List<MetricBean> dataTable = null;
      if (fromTable.equals("table_verygood")) {
        dataTable = this.lVeryGoodMT;
      }
      if (fromTable.equals("table_good")) {
        dataTable = this.lGoodMT;
      }
      if (fromTable.equals("table_bad")) {
        dataTable = this.lBadMT;
      }
      if (fromTable.equals("table_verybad")) {
        dataTable = this.lVeryBadMT;
      }
      // check from which table to remove the data
      MetricBean del = null;
      Iterator<MetricBean> itTableData = dataTable.iterator();
      while (itTableData.hasNext()) {
        MetricBean mb = itTableData.next();
        if (mb.getInternalID().equals(removeMetricID)) {
          del = mb;
        }
      }
      if (del != null) dataTable.remove(del);
    }
  }
 public List<MetricBean> getAllSupportedEvalMetrics() {
   List<MetricBean> lret = new ArrayList<MetricBean>();
   if (evalSerTemplate != null) {
     Map<String, List<Map<String, String>>> mapMetricInfo =
         evalSerTemplate.getAllAvailableMetricsForBMGoal(sBMGoalID);
     if ((mapMetricInfo != null) && (mapMetricInfo.size() > 0)) {
       Iterator<String> itKeys = mapMetricInfo.keySet().iterator();
       // iterate over all parameter names e.g. imageWidth
       while (itKeys.hasNext()) {
         List<Map<String, String>> l = mapMetricInfo.get(itKeys.next());
         for (Map<String, String> m : l) {
           String sMname = m.get("metricName");
           String sMDescr = m.get("metricDescription");
           String sMretType = m.get("javaobjecttype");
           // create metricbean object and add into the return list
           MetricBean mb = new MetricBean(sMname, sMDescr);
           mb.setDescription(sMDescr);
           this.mapMetricNameType.put(sMname, sMretType);
           lret.add(mb);
         }
       }
     }
   }
   return lret;
 }
  /**
   * Takes a parent UIComponent and adds all UIComponents which are required for configuring a
   * metric. i.e. metric name, math expression, value, etc.
   *
   * @param metric
   * @param parent
   */
  private void helperCreateUICompsForMetricConfig(MetricBean metric, UIComponent parent) {

    // 1)remove all existing child elements that may have been created previously from ALL
    // pConfigVeryGood, pConfigGood, etc.
    removeAllInputHelpersForMetricConfig();

    // 2) now build the gui elements for building a metric configuration
    // 2a) Add an output text with the metric's name
    HtmlOutputText mnameText = new HtmlOutputText();
    mnameText.setId("metricName" + metric.getInternalID());
    mnameText.setValue(metric.getName());
    // add on parent
    parent.getChildren().add(mnameText);

    // 2b) Select a math expression
    HtmlSelectOneMenu select2 = new HtmlSelectOneMenu();
    select2.setId("mathSelect" + metric.getInternalID());
    UISelectItems items2 = new UISelectItems();
    items2.setId("mathvals" + metric.getInternalID());
    items2.setValue(metric.getAllAvailableTypes());
    Class[] parms2 = new Class[] {ValueChangeEvent.class};
    ExpressionFactory ef =
        FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
    MethodExpression mb =
        ef.createMethodExpression(
            FacesContext.getCurrentInstance().getELContext(),
            "#{AutoEvalSerUserConfigBean.processMathExprChange}",
            null,
            parms2);
    MethodExpressionValueChangeListener vcl = new MethodExpressionValueChangeListener(mb);
    select2.addValueChangeListener(vcl);
    select2.getChildren().add(items2);
    select2.setImmediate(true);

    // place an ajax support on the selectonemenu field
    HtmlAjaxSupport ajaxSupport2 = new HtmlAjaxSupport();
    // Class[] parms = new Class[]{ActionEvent.class};
    // ajaxSupport.setAction(FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{AutoEvalSerUserConfigBean.sliderValue}", parms));
    ajaxSupport2.setEvent("onchange");
    // to add multiple ids for rerendering, separate them with a ","
    ajaxSupport2.setReRender(select2.getId());
    ajaxSupport2.setEventsQueue("foo");
    select2.getFacets().put("a4jsupport2", ajaxSupport2);

    // add to parent
    parent.getChildren().add(select2);

    // 2c) For all input types except boolean values:
    if (metric.isHtmlInputTextUsed()) {
      // enter a boundary value for a specific added metric
      HtmlInputText inputText = new HtmlInputText();
      inputText.setId("metricBoundary" + metric.getInternalID());
      inputText.setValue(metric.getEvalBoundary());
      inputText.setSize(10);
      Class[] parms = new Class[] {ValueChangeEvent.class};
      MethodExpression mb2 =
          ef.createMethodExpression(
              FacesContext.getCurrentInstance().getELContext(),
              "#{AutoEvalSerUserConfigBean.processMetricBoundaryValueChange}",
              null,
              parms);
      MethodExpressionValueChangeListener vcl2 = new MethodExpressionValueChangeListener(mb2);
      inputText.addValueChangeListener(vcl2);
      inputText.setImmediate(true);

      // place an ajax support on the InputText field
      HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();
      // Class[] parms = new Class[]{ActionEvent.class};
      // ajaxSupport.setAction(FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{AutoEvalSerUserConfigBean.sliderValue}", parms));
      ajaxSupport.setEvent("onchange");
      // to add multiple ids for rerendering, separate them with a ","
      ajaxSupport.setReRender(inputText.getId());
      ajaxSupport.setEventsQueue("foo");
      inputText.getFacets().put("a4jsupport", ajaxSupport);

      // add to parent
      parent.getChildren().add(inputText);
    } else {
      // add a drop-down box for boolean values
      HtmlSelectOneMenu select = new HtmlSelectOneMenu();
      select.setId("booleanSelect" + metric.getInternalID());
      UISelectItems items = new UISelectItems();
      items.setId("vals" + metric.getInternalID());
      List<SelectItem> l = new ArrayList<SelectItem>();
      l.add(new SelectItem("true"));
      l.add(new SelectItem("false"));
      items.setValue(l);
      Class[] parms = new Class[] {ValueChangeEvent.class};
      MethodExpression mb3 =
          ef.createMethodExpression(
              FacesContext.getCurrentInstance().getELContext(),
              "#{AutoEvalSerUserConfigBean.processMetricBoundaryValueChange}",
              null,
              parms);
      MethodExpressionValueChangeListener vcl3 = new MethodExpressionValueChangeListener(mb3);
      select.addValueChangeListener(vcl3);
      select.getChildren().add(items);
      select.setImmediate(true);

      // place an ajax support on the selectonemenu field
      HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();
      // Class[] parms = new Class[]{ActionEvent.class};
      // ajaxSupport.setAction(FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{AutoEvalSerUserConfigBean.sliderValue}", parms));
      ajaxSupport.setEvent("onchange");
      // to add multiple ids for rerendering, separate them with a ","
      ajaxSupport.setReRender(select.getId());
      ajaxSupport.setEventsQueue("foo");
      select.getFacets().put("a4jsupport", ajaxSupport);

      // add to parent
      parent.getChildren().add(select);
    }

    // 2d) finally the submit button for saving the configuration
    HtmlCommandButton button_save = new HtmlCommandButton();
    button_save.setId("buttonSave" + metric.getInternalID());
    button_save.setValue("add config");
    Class[] parms3 = new Class[] {ActionEvent.class};
    MethodExpression mb4 =
        ef.createMethodExpression(
            FacesContext.getCurrentInstance().getELContext(),
            "#{AutoEvalSerUserConfigBean.command_saveMetricConfiguration}",
            null,
            parms3);
    MethodExpressionActionListener vcl4 = new MethodExpressionActionListener(mb4);
    button_save.addActionListener(vcl4);
    UIParameter p = new UIParameter();
    p.setId("param_save_button" + metric.getInternalID());
    p.setName("pConfigPanel");
    p.setValue(parent.getId());
    button_save.getChildren().add(p);

    parent.getChildren().add(button_save);

    HtmlOutputText message = new HtmlOutputText();
    message.setId("message" + metric.getInternalID());
    message.setStyle("color:red;");
    parent.getChildren().add(message);
  }