Program: 56897
Project: 56897
Buggy source:
/** 
 * This methods generates the HTML code of the current b:dataTable. <code>encodeBegin</code> generates the start of the component. After the, the JSF framework calls <code>encodeChildren()</code> to generate the HTML code between the beginning and the end of the component. For instance, in the case of a panel component the content of the panel is generated by <code>encodeChildren()</code>. After that, <code>encodeEnd()</code> is called to generate the rest of the HTML code.
 * @param context the FacesContext.
 * @param component the current b:dataTable.
 * @throws IOException thrown if something goes wrong when writing the HTML code.
 */
@Override public void encodeEnd(FacesContext context,UIComponent component) throws IOException {
  if (!component.isRendered()) {
    return;
  }
  DataTable dataTable=(DataTable)component;
  Map<Integer,String> columnSortOrder=dataTable.getColumnSortOrderMap();
  int pageLength=dataTable.getPageLength();
  String orderString="String_Node_Str";
  if (columnSortOrder != null) {
    StringBuilder sb=new StringBuilder();
    int i=0;
    for (    Map.Entry<Integer,String> entry : columnSortOrder.entrySet()) {
      String separator=(i > 0) ? "String_Node_Str" : "String_Node_Str";
      sb.append(separator).append("String_Node_Str").append(entry.getKey()).append("String_Node_Str").append("String_Node_Str").append(entry.getValue()).append("String_Node_Str").append("String_Node_Str");
      i++;
    }
    orderString=sb.toString();
  }
  ResponseWriter rw=context.getResponseWriter();
  String clientIdRaw=dataTable.getClientId();
  String clientId=clientIdRaw.replace("String_Node_Str","String_Node_Str");
  String widgetVar=dataTable.getWidgetVar();
  if (null == widgetVar) {
    widgetVar=BsfUtils.widgetVarName(clientIdRaw);
  }
  String lang=determineLanguage(context,dataTable);
  rw.endElement("String_Node_Str");
  endDisabledFieldset(dataTable,rw);
  String responsiveStyle=Responsive.getResponsiveStyleClass(dataTable,false);
  if (null != responsiveStyle && responsiveStyle.trim().length() > 0) {
    rw.endElement("String_Node_Str");
  }
  if (dataTable.isScrollHorizontally()) {
    rw.endElement("String_Node_Str");
  }
  Tooltip.activateTooltips(context,dataTable);
  rw.startElement("String_Node_Str",component);
  rw.writeText("String_Node_Str",null);
  String options="String_Node_Str";
  options=addOptions("String_Node_Str" + dataTable.isFixedHeader(),options);
  options=addOptions("String_Node_Str" + dataTable.isResponsive(),options);
  options=addOptions("String_Node_Str" + dataTable.isPaginated(),options);
  if (!dataTable.isInfo()) {
    options=addOptions("String_Node_Str",options);
  }
  options=addOptions("String_Node_Str" + pageLength,options);
  options=addOptions("String_Node_Str" + getPageLengthMenu(dataTable),options);
  options=addOptions("String_Node_Str" + dataTable.isSearching(),options);
  options=addOptions("String_Node_Str" + orderString,options);
  options=addOptions("String_Node_Str" + dataTable.isSaveState(),options);
  options=addOptions("String_Node_Str",options);
  if (dataTable.isSelect()) {
    String json="String_Node_Str";
    String items=dataTable.getSelectedItems();
    if ("String_Node_Str".equals(items) || "String_Node_Str".equals(items)) {
      json+="String_Node_Str";
    }
 else     if ("String_Node_Str".equals(items) || "String_Node_Str".equals(items)) {
      json+="String_Node_Str";
    }
    if ("String_Node_Str".equalsIgnoreCase(dataTable.getSelectionMode())) {
      json+="String_Node_Str";
    }
 else {
      json+="String_Node_Str";
    }
    if (!dataTable.isSelectionInfo()) {
      json+="String_Node_Str";
    }
    if (dataTable.isDeselectOnBackdropClick()) {
      json+="String_Node_Str";
    }
    if (json.length() > 1) {
      json="String_Node_Str" + json.substring(0,json.length() - 1) + "String_Node_Str";
    }
 else {
      json="String_Node_Str";
    }
    options=addOptions(json,options);
  }
  options=addOptions(generateScrollOptions(dataTable),options);
  options=addOptions((BsfUtils.isStringValued(lang) ? "String_Node_Str" + lang + "String_Node_Str" : null),options);
  options=addOptions(generateColumnInfos(dataTable.getColumnInfo()),options);
  options=addOptions(dataTable.getCustomOptions(),options);
  options=addOptions(getButtons(dataTable),options);
  String selectCommand="String_Node_Str";
  Object selectedRow=dataTable.getSelectedRow();
  if (null != selectedRow) {
    String selector="String_Node_Str";
    if (selectedRow instanceof String) {
      try {
        Integer.parseInt((String)selectedRow);
        selector=(String)selectedRow;
      }
 catch (      NumberFormatException itIsAString) {
        selector="String_Node_Str" + selectedRow + "String_Node_Str";
      }
    }
 else     if (selectedRow instanceof Number) {
      selector=selectedRow.toString();
    }
    selectCommand=widgetVar + "String_Node_Str" + selector+ "String_Node_Str";
  }
  Object selectedColumn=dataTable.getSelectedColumn();
  if (null != selectedColumn) {
    String selector="String_Node_Str";
    if (selectedColumn instanceof String) {
      try {
        Integer.parseInt((String)selectedColumn);
        selector=(String)selectedColumn;
      }
 catch (      NumberFormatException itIsAString) {
        selector="String_Node_Str" + selectedColumn + "String_Node_Str";
      }
    }
 else     if (selectedColumn instanceof Number) {
      selector=selectedColumn.toString();
    }
    selectCommand+=widgetVar + "String_Node_Str" + selector+ "String_Node_Str";
  }
  if (selectCommand.length() > 0) {
    options=addOptions("String_Node_Str" + selectCommand + "String_Node_Str",options);
  }
  if (dataTable.getRowGroup() != null) {
    String rowGroup=dataTable.getRowGroup();
    try {
      Integer.parseInt(rowGroup);
      options=addOptions("String_Node_Str" + rowGroup + "String_Node_Str",options);
      rowGroup="String_Node_Str" + rowGroup + "String_Node_Str";
    }
 catch (    NumberFormatException itsJson) {
    }
    options=addOptions(rowGroup,options);
  }
  rw.writeText(widgetVar + "String_Node_Str" + clientId+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ clientIdRaw.replace("String_Node_Str","String_Node_Str")+ "String_Node_Str"+ "String_Node_Str"+ widgetVar+ "String_Node_Str"+ "String_Node_Str"+ widgetVar+ "String_Node_Str"+ options+ "String_Node_Str",null);
  if (dataTable.isMultiColumnSearch()) {
    String filter="String_Node_Str";
    filter+="String_Node_Str";
    filter+="String_Node_Str";
    filter+="String_Node_Str";
    rw.writeText(widgetVar + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ filter+ "String_Node_Str"+ "String_Node_Str",null);
    rw.writeText("String_Node_Str" + widgetVar + "String_Node_Str",null);
    rw.writeText("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",null);
    rw.writeText("String_Node_Str",null);
    int col=0;
    for (    UIComponent column : dataTable.getChildren()) {
      if (!column.isRendered()) {
        continue;
      }
      String searchValue=null;
      if ((column instanceof DataTableColumn)) {
        searchValue=((DataTableColumn)column).getSearchValue();
      }
 else {
        Object sv=column.getAttributes().get("String_Node_Str");
        if (sv != null && (!"String_Node_Str".equals(sv))) {
          searchValue=sv.toString();
        }
      }
      if (null != searchValue) {
        rw.writeText("String_Node_Str" + col + "String_Node_Str"+ searchValue+ "String_Node_Str",null);
        rw.writeText("String_Node_Str" + col + "String_Node_Str"+ searchValue+ "String_Node_Str",null);
      }
      col++;
    }
  }
  rw.writeText("String_Node_Str",null);
  rw.endElement("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * This methods generates the HTML code of the current b:dataTable. <code>encodeBegin</code> generates the start of the component. After the, the JSF framework calls <code>encodeChildren()</code> to generate the HTML code between the beginning and the end of the component. For instance, in the case of a panel component the content of the panel is generated by <code>encodeChildren()</code>. After that, <code>encodeEnd()</code> is called to generate the rest of the HTML code.
 * @param context the FacesContext.
 * @param component the current b:dataTable.
 * @throws IOException thrown if something goes wrong when writing the HTML code.
 */
@Override public void encodeEnd(FacesContext context,UIComponent component) throws IOException {
  if (!component.isRendered()) {
    return;
  }
  DataTable dataTable=(DataTable)component;
  Map<Integer,String> columnSortOrder=dataTable.getColumnSortOrderMap();
  int pageLength=dataTable.getPageLength();
  String orderString="String_Node_Str";
  if (columnSortOrder != null) {
    StringBuilder sb=new StringBuilder();
    int i=0;
    for (    Map.Entry<Integer,String> entry : columnSortOrder.entrySet()) {
      String separator=(i > 0) ? "String_Node_Str" : "String_Node_Str";
      sb.append(separator).append("String_Node_Str").append(entry.getKey()).append("String_Node_Str").append("String_Node_Str").append(entry.getValue()).append("String_Node_Str").append("String_Node_Str");
      i++;
    }
    orderString=sb.toString();
  }
  ResponseWriter rw=context.getResponseWriter();
  String clientIdRaw=dataTable.getClientId();
  String clientId=clientIdRaw.replace("String_Node_Str","String_Node_Str");
  String widgetVar=dataTable.getWidgetVar();
  if (null == widgetVar) {
    widgetVar=BsfUtils.widgetVarName(clientIdRaw);
  }
  String lang=determineLanguage(context,dataTable);
  rw.endElement("String_Node_Str");
  endDisabledFieldset(dataTable,rw);
  String responsiveStyle=Responsive.getResponsiveStyleClass(dataTable,false);
  if (null != responsiveStyle && responsiveStyle.trim().length() > 0) {
    rw.endElement("String_Node_Str");
  }
  if (dataTable.isScrollHorizontally()) {
    rw.endElement("String_Node_Str");
  }
  Tooltip.activateTooltips(context,dataTable);
  rw.startElement("String_Node_Str",component);
  rw.writeText("String_Node_Str",null);
  String options="String_Node_Str";
  options=addOptions("String_Node_Str" + dataTable.isFixedHeader(),options);
  options=addOptions("String_Node_Str" + dataTable.isResponsive(),options);
  options=addOptions("String_Node_Str" + dataTable.isPaginated(),options);
  if (!dataTable.isInfo()) {
    options=addOptions("String_Node_Str",options);
  }
  options=addOptions("String_Node_Str" + pageLength,options);
  options=addOptions("String_Node_Str" + getPageLengthMenu(dataTable),options);
  options=addOptions("String_Node_Str" + dataTable.isSearching(),options);
  options=addOptions("String_Node_Str" + orderString,options);
  options=addOptions("String_Node_Str" + dataTable.isSaveState(),options);
  options=addOptions("String_Node_Str",options);
  if (dataTable.isSelect()) {
    String json="String_Node_Str";
    String items=dataTable.getSelectedItems();
    if ("String_Node_Str".equals(items) || "String_Node_Str".equals(items)) {
      json+="String_Node_Str";
    }
 else     if ("String_Node_Str".equals(items) || "String_Node_Str".equals(items)) {
      json+="String_Node_Str";
    }
    if ("String_Node_Str".equalsIgnoreCase(dataTable.getSelectionMode())) {
      json+="String_Node_Str";
    }
 else {
      json+="String_Node_Str";
    }
    if (!dataTable.isSelectionInfo()) {
      json+="String_Node_Str";
    }
    if (dataTable.isDeselectOnBackdropClick()) {
      json+="String_Node_Str";
    }
    if (json.length() > 1) {
      json="String_Node_Str" + json.substring(0,json.length() - 1) + "String_Node_Str";
    }
 else {
      json="String_Node_Str";
    }
    options=addOptions(json,options);
  }
  options=addOptions(generateScrollOptions(dataTable),options);
  options=addOptions((BsfUtils.isStringValued(lang) ? "String_Node_Str" + lang + "String_Node_Str" : null),options);
  options=addOptions(generateColumnInfos(dataTable.getColumnInfo()),options);
  options=addOptions(dataTable.getCustomOptions(),options);
  options=addOptions(getButtons(dataTable),options);
  String selectCommand="String_Node_Str";
  Object selectedRow=dataTable.getSelectedRow();
  if (null != selectedRow) {
    String selector="String_Node_Str";
    if (selectedRow instanceof String) {
      try {
        Integer.parseInt((String)selectedRow);
        selector=(String)selectedRow;
      }
 catch (      NumberFormatException itIsAString) {
        selector="String_Node_Str" + selectedRow + "String_Node_Str";
      }
    }
 else     if (selectedRow instanceof Number) {
      selector=selectedRow.toString();
    }
    selectCommand=widgetVar + "String_Node_Str" + selector+ "String_Node_Str";
  }
  Object selectedColumn=dataTable.getSelectedColumn();
  if (null != selectedColumn) {
    String selector="String_Node_Str";
    if (selectedColumn instanceof String) {
      try {
        Integer.parseInt((String)selectedColumn);
        selector=(String)selectedColumn;
      }
 catch (      NumberFormatException itIsAString) {
        selector="String_Node_Str" + selectedColumn + "String_Node_Str";
      }
    }
 else     if (selectedColumn instanceof Number) {
      selector=selectedColumn.toString();
    }
    selectCommand+=widgetVar + "String_Node_Str" + selector+ "String_Node_Str";
  }
  if (selectCommand.length() > 0) {
    options=addOptions("String_Node_Str" + selectCommand + "String_Node_Str",options);
  }
  if (dataTable.getRowGroup() != null) {
    String rowGroup=dataTable.getRowGroup();
    try {
      Integer.parseInt(rowGroup);
      options=addOptions("String_Node_Str" + rowGroup + "String_Node_Str",options);
      rowGroup="String_Node_Str" + rowGroup + "String_Node_Str";
    }
 catch (    NumberFormatException itsJson) {
    }
    options=addOptions(rowGroup,options);
  }
  rw.writeText(widgetVar + "String_Node_Str" + clientId+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ clientIdRaw.replace("String_Node_Str","String_Node_Str")+ "String_Node_Str"+ "String_Node_Str"+ widgetVar+ "String_Node_Str"+ "String_Node_Str"+ widgetVar+ "String_Node_Str"+ options+ "String_Node_Str",null);
  if (dataTable.isMultiColumnSearch()) {
    String filter="String_Node_Str";
    filter+="String_Node_Str";
    filter+="String_Node_Str";
    filter+="String_Node_Str";
    rw.writeText(widgetVar + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ filter+ "String_Node_Str"+ "String_Node_Str",null);
    rw.writeText("String_Node_Str" + widgetVar + "String_Node_Str",null);
    rw.writeText("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",null);
    rw.writeText("String_Node_Str",null);
    int col=0;
    for (    UIComponent column : dataTable.getChildren()) {
      if (!column.isRendered()) {
        continue;
      }
      String searchValue=null;
      if ((column instanceof DataTableColumn)) {
        searchValue=((DataTableColumn)column).getSearchValue();
        if (!((DataTableColumn)column).isSearchable()) {
          continue;
        }
      }
 else {
        Object sv=column.getAttributes().get("String_Node_Str");
        if (sv != null && (!"String_Node_Str".equals(sv))) {
          searchValue=sv.toString();
        }
      }
      if (null != searchValue && searchValue.length() > 0) {
        rw.writeText("String_Node_Str" + col + "String_Node_Str"+ searchValue+ "String_Node_Str",null);
        rw.writeText("String_Node_Str" + col + "String_Node_Str"+ searchValue+ "String_Node_Str",null);
      }
      col++;
    }
  }
  rw.writeText("String_Node_Str",null);
  rw.endElement("String_Node_Str");
}