Program: 143761
Project: 143761
Buggy source:
public WebCellBasedView(final String id,final IApplication application,final Form form,final AbstractBase cellview,final IDataProviderLookup dataProviderLookup,final IScriptExecuter el,boolean addHeaders,final int startY,final int endY,final int sizeHint){
  super(id);
  this.application=application;
  this.cellview=cellview;
  this.fc=el.getFormController();
  this.addHeaders=addHeaders;
  this.startY=startY;
  this.endY=endY;
  this.formDesignHeight=form.getSize().height;
  this.sizeHint=sizeHint;
  this.bodyWidthHint=form.getWidth();
  useAJAX=Utils.getAsBoolean(application.getRuntimeProperties().get("String_Node_Str"));
  useAnchors=Utils.getAsBoolean(application.getRuntimeProperties().get("String_Node_Str"));
  setOutputMarkupPlaceholderTag(true);
  dataRendererOnRenderWrapper=new DataRendererOnRenderWrapper(this);
  if (!useAJAX)   bodyHeightHint=sizeHint;
  jsChangeRecorder=new ChangesRecorder(null,null){
    @Override public boolean isChanged(){
      boolean retval=false;
      if (super.isChanged()) {
        retval=true;
        return retval;
      }
      if (!retval) {
        Iterator<Component> iterator=elementToColumnIdentifierComponent.values().iterator();
        while (iterator.hasNext()) {
          Component object=iterator.next();
          if (object instanceof IProviderStylePropertyChanges) {
            if (((IProviderStylePropertyChanges)object).getStylePropertyChanges().isChanged()) {
              retval=true;
              break;
            }
          }
        }
      }
      if (retval) {
        MainPage page=(MainPage)getPage();
        page.getPageContributor().addTableToRender(WebCellBasedView.this);
        setRendered();
      }
      return false;
    }
    @Override public void setRendered(){
      super.setRendered();
      Iterator<Component> iterator=elementToColumnIdentifierComponent.values().iterator();
      while (iterator.hasNext()) {
        Component comp=iterator.next();
        if (comp instanceof IProviderStylePropertyChanges) {
          ((IProviderStylePropertyChanges)comp).getStylePropertyChanges().setRendered();
        }
      }
    }
  }
;
  add(new StyleAppendingModifier(new Model<String>(){
    private static final long serialVersionUID=1L;
    @Override public String getObject(){
      WebTabPanel tabpanel=findParent(WebTabPanel.class);
      if (tabpanel != null) {
        return "String_Node_Str";
      }
      return "String_Node_Str";
    }
  }
));
  if (cellview instanceof BaseComponent) {
    ComponentFactory.applyBasicComponentProperties(application,this,(BaseComponent)cellview,ComponentFactory.getStyleForBasicComponent(application,(BaseComponent)cellview,form));
  }
  boolean sortable=true;
  String initialSortString=null;
  int onRenderMethodID=0;
  if (cellview instanceof Portal) {
    Portal p=(Portal)cellview;
    setRowBGColorScript(p.getRowBGColorCalculation(),p.getInstanceMethodArguments("String_Node_Str"));
    sortable=p.getSortable();
    initialSortString=p.getInitialSort();
    onRenderMethodID=p.getOnRenderMethodID();
  }
 else   if (cellview instanceof Form) {
    initialSortString=form.getInitialSort();
    onRenderMethodID=form.getOnRenderMethodID();
  }
  if (onRenderMethodID > 0) {
    dataRendererOnRenderWrapper.getRenderEventExecutor().setRenderCallback(Integer.toString(onRenderMethodID));
    dataRendererOnRenderWrapper.getRenderEventExecutor().setRenderScriptExecuter(fc != null ? fc.getScriptExecuter() : null);
  }
  initDragNDrop(fc,startY);
  if (sortable) {
    if (initialSortString != null) {
      StringTokenizer tokByComma=new StringTokenizer(initialSortString,"String_Node_Str");
      if (tokByComma.hasMoreTokens()) {
        String initialSortFirstToken=tokByComma.nextToken();
        StringTokenizer tokBySpace=new StringTokenizer(initialSortFirstToken);
        if (tokBySpace.hasMoreTokens()) {
          initialSortColumnName=tokBySpace.nextToken();
          if (tokBySpace.hasMoreTokens()) {
            String sortDir=tokBySpace.nextToken();
            if (sortDir.equalsIgnoreCase("String_Node_Str"))             initialSortAsc=false;
          }
        }
      }
    }
    if (initialSortColumnName == null) {
      try {
        String dataSource=null;
        if (cellview instanceof Portal) {
          Portal p=(Portal)cellview;
          String relation=p.getRelationName();
          int lastDot=relation.lastIndexOf("String_Node_Str");
          if (lastDot >= 0) {
            relation=relation.substring(lastDot + 1);
          }
          Relation rel=application.getFlattenedSolution().getRelation(relation);
          if (rel != null) {
            dataSource=rel.getForeignDataSource();
          }
        }
 else {
          dataSource=form.getDataSource();
        }
        if (dataSource != null) {
          Iterator<String> pkColumnNames=application.getFoundSetManager().getTable(dataSource).getRowIdentColumnNames();
          if (pkColumnNames.hasNext()) {
            initialSortColumnName=pkColumnNames.next();
            initialSortAsc=true;
          }
        }
      }
 catch (      RepositoryException e) {
        Debug.log("String_Node_Str",e);
      }
    }
  }
  maxHeight=0;
  try {
    Iterator<IPersist> components=cellview.getAllObjects(PositionComparator.XY_PERSIST_COMPARATOR);
    while (components.hasNext()) {
      IPersist element=components.next();
      if (element instanceof Field || element instanceof GraphicalComponent) {
        if (element instanceof GraphicalComponent && ((GraphicalComponent)element).getLabelFor() != null) {
          labelsFor.put(((GraphicalComponent)element).getLabelFor(),element);
          continue;
        }
        Point l=((IFormElement)element).getLocation();
        if (l == null) {
          continue;
        }
        if (l.y >= startY && l.y < endY) {
          int height=((IFormElement)element).getSize().height;
          if (height > maxHeight)           maxHeight=height;
        }
      }
    }
    if (maxHeight == 0)     maxHeight=20;
  }
 catch (  Exception ex1) {
    Debug.error("String_Node_Str",ex1);
  }
  table=new WebCellBasedViewListView("String_Node_Str",data,1,cellview,dataProviderLookup,el,startY,endY,form);
  table.setReuseItems(true);
  add(table);
  final LinkedHashMap<String,IDataAdapter> dataadapters=new LinkedHashMap<String,IDataAdapter>();
  final SortedList<IPersist> columnTabSequence=new SortedList<IPersist>(TabSeqComparator.INSTANCE);
  createComponents(application,form,cellview,dataProviderLookup,el,startY,endY,new ItemAdd(){
    public void add(    IPersist element,    Component comp){
      if (element instanceof IFormElement && comp instanceof IComponent) {
        ((IComponent)comp).setLocation(((IFormElement)element).getLocation());
        ((IComponent)comp).setSize(((IFormElement)element).getSize());
      }
      elementToColumnIdentifierComponent.put(element,comp);
      if (cellview instanceof Form && element instanceof ISupportTabSeq && ((ISupportTabSeq)element).getTabSeq() >= 0) {
        columnTabSequence.add(element);
      }
      if (comp instanceof IDisplayData) {
        String dataprovider=((IDisplayData)comp).getDataProviderID();
        WebCellAdapter previous=(WebCellAdapter)dataadapters.get(dataprovider);
        if (previous == null) {
          WebCellAdapter wca=new WebCellAdapter(dataprovider,WebCellBasedView.this);
          dataadapters.put(dataprovider,wca);
        }
        if (dataprovider != null) {
          if (dataprovider.equals(initialSortColumnName))           initialSortedColumnId=comp.getId();
        }
      }
    }
  }
);
  for (int i=columnTabSequence.size() - 1; i >= 0; i--) {
    elementTabIndexes.put(columnTabSequence.get(i),Integer.valueOf(i));
  }
  if (addHeaders) {
    headers=new SortableCellViewHeaders(form,this,"String_Node_Str",table,cellview,application,initialSortedColumnId,initialSortAsc,new IHeaders(){
      public void registerHeader(      IPersist matchingElement,      Component headerComponent){
        SortableCellViewHeader sortableHeader=(SortableCellViewHeader)headerComponent;
        Component columnIdentifier=WebCellBasedView.this.elementToColumnIdentifierComponent.get(matchingElement);
        if (columnIdentifier instanceof IProviderStylePropertyChanges) {
          String width=(String)((IProviderStylePropertyChanges)columnIdentifier).getStylePropertyChanges().getChanges().get("String_Node_Str");
          if (width != null) {
            sortableHeader.setWidth(Integer.parseInt(width.substring(0,width.length() - 2)));
          }
 else           if (matchingElement instanceof BaseComponent)           sortableHeader.setWidth(((BaseComponent)matchingElement).getSize().width);
        }
        sortableHeader.setTabIndex(tabIndex);
        sortableHeader.setScriptExecuter(el);
        WebCellBasedView.this.registerHeader(matchingElement,headerComponent);
      }
    }
);
    add(headers);
  }
  if (useAJAX) {
    add(pagingNavigator=new ServoyAjaxPagingNavigator("String_Node_Str",table));
    add(new ServoyTableResizeBehavior(startY,endY,cellview));
  }
 else {
    add(pagingNavigator=new ServoySubmitPagingNavigator("String_Node_Str",table));
  }
  int scrollbars=0;
  if (cellview instanceof Portal) {
    scrollbars=((Portal)cellview).getScrollbars();
  }
  if (cellview instanceof Form) {
    scrollbars=((Form)cellview).getScrollbars();
  }
  showPageNavigator=!((scrollbars & ISupportScrollbars.VERTICAL_SCROLLBAR_NEVER) == ISupportScrollbars.VERTICAL_SCROLLBAR_NEVER);
  try {
    if (cellview instanceof Portal) {
      relationName=((Portal)cellview).getRelationName();
      Relation[] rels=application.getFlattenedSolution().getRelationSequence(((Portal)cellview).getRelationName());
      if (rels != null) {
        Relation r=rels[rels.length - 1];
        if (r != null) {
          defaultSort=((FoundSetManager)application.getFoundSetManager()).getSortColumns(application.getFoundSetManager().getTable(r.getForeignDataSource()),((Portal)cellview).getInitialSort());
        }
      }
    }
 else {
      defaultSort=((FoundSetManager)application.getFoundSetManager()).getSortColumns(((Form)cellview).getDataSource(),((Form)cellview).getInitialSort());
    }
  }
 catch (  RepositoryException e) {
    Debug.error(e);
    defaultSort=new ArrayList<SortColumn>(1);
  }
  try {
    dal=new DataAdapterList(application,dataProviderLookup,elementToColumnIdentifierComponent,el.getFormController(),dataadapters,null);
  }
 catch (  RepositoryException ex) {
    Debug.error(ex);
  }
}

Fixed version (ground truth):
public WebCellBasedView(final String id,final IApplication application,final Form form,final AbstractBase cellview,final IDataProviderLookup dataProviderLookup,final IScriptExecuter el,boolean addHeaders,final int startY,final int endY,final int sizeHint){
  super(id);
  this.application=application;
  this.cellview=cellview;
  this.fc=el.getFormController();
  this.addHeaders=addHeaders;
  this.startY=startY;
  this.endY=endY;
  this.formDesignHeight=form.getSize().height;
  this.sizeHint=sizeHint;
  this.bodyWidthHint=form.getWidth();
  useAJAX=Utils.getAsBoolean(application.getRuntimeProperties().get("String_Node_Str"));
  useAnchors=Utils.getAsBoolean(application.getRuntimeProperties().get("String_Node_Str"));
  setOutputMarkupPlaceholderTag(true);
  dataRendererOnRenderWrapper=new DataRendererOnRenderWrapper(this);
  if (!useAJAX)   bodyHeightHint=sizeHint;
  jsChangeRecorder=new ChangesRecorder(null,null){
    @Override public boolean isChanged(){
      boolean retval=false;
      if (super.isChanged()) {
        retval=true;
        return retval;
      }
      if (!retval) {
        Iterator<Component> iterator=elementToColumnIdentifierComponent.values().iterator();
        while (iterator.hasNext()) {
          Component object=iterator.next();
          if (object instanceof IProviderStylePropertyChanges) {
            if (((IProviderStylePropertyChanges)object).getStylePropertyChanges().isChanged()) {
              retval=true;
              break;
            }
          }
        }
      }
      if (retval) {
        MainPage page=(MainPage)getPage();
        page.getPageContributor().addTableToRender(WebCellBasedView.this);
        setRendered();
      }
      return false;
    }
    @Override public void setRendered(){
      super.setRendered();
      Iterator<Component> iterator=elementToColumnIdentifierComponent.values().iterator();
      while (iterator.hasNext()) {
        Component comp=iterator.next();
        if (comp instanceof IProviderStylePropertyChanges) {
          ((IProviderStylePropertyChanges)comp).getStylePropertyChanges().setRendered();
        }
      }
    }
  }
;
  add(new StyleAppendingModifier(new Model<String>(){
    private static final long serialVersionUID=1L;
    @Override public String getObject(){
      WebTabPanel tabpanel=findParent(WebTabPanel.class);
      if (tabpanel != null) {
        return "String_Node_Str";
      }
 else {
        WebSplitPane splitPane=findParent(WebSplitPane.class);
        if (splitPane != null) {
          return "String_Node_Str";
        }
      }
      return "String_Node_Str";
    }
  }
));
  if (cellview instanceof BaseComponent) {
    ComponentFactory.applyBasicComponentProperties(application,this,(BaseComponent)cellview,ComponentFactory.getStyleForBasicComponent(application,(BaseComponent)cellview,form));
  }
  boolean sortable=true;
  String initialSortString=null;
  int onRenderMethodID=0;
  if (cellview instanceof Portal) {
    Portal p=(Portal)cellview;
    setRowBGColorScript(p.getRowBGColorCalculation(),p.getInstanceMethodArguments("String_Node_Str"));
    sortable=p.getSortable();
    initialSortString=p.getInitialSort();
    onRenderMethodID=p.getOnRenderMethodID();
  }
 else   if (cellview instanceof Form) {
    initialSortString=form.getInitialSort();
    onRenderMethodID=form.getOnRenderMethodID();
  }
  if (onRenderMethodID > 0) {
    dataRendererOnRenderWrapper.getRenderEventExecutor().setRenderCallback(Integer.toString(onRenderMethodID));
    dataRendererOnRenderWrapper.getRenderEventExecutor().setRenderScriptExecuter(fc != null ? fc.getScriptExecuter() : null);
  }
  initDragNDrop(fc,startY);
  if (sortable) {
    if (initialSortString != null) {
      StringTokenizer tokByComma=new StringTokenizer(initialSortString,"String_Node_Str");
      if (tokByComma.hasMoreTokens()) {
        String initialSortFirstToken=tokByComma.nextToken();
        StringTokenizer tokBySpace=new StringTokenizer(initialSortFirstToken);
        if (tokBySpace.hasMoreTokens()) {
          initialSortColumnName=tokBySpace.nextToken();
          if (tokBySpace.hasMoreTokens()) {
            String sortDir=tokBySpace.nextToken();
            if (sortDir.equalsIgnoreCase("String_Node_Str"))             initialSortAsc=false;
          }
        }
      }
    }
    if (initialSortColumnName == null) {
      try {
        String dataSource=null;
        if (cellview instanceof Portal) {
          Portal p=(Portal)cellview;
          String relation=p.getRelationName();
          int lastDot=relation.lastIndexOf("String_Node_Str");
          if (lastDot >= 0) {
            relation=relation.substring(lastDot + 1);
          }
          Relation rel=application.getFlattenedSolution().getRelation(relation);
          if (rel != null) {
            dataSource=rel.getForeignDataSource();
          }
        }
 else {
          dataSource=form.getDataSource();
        }
        if (dataSource != null) {
          Iterator<String> pkColumnNames=application.getFoundSetManager().getTable(dataSource).getRowIdentColumnNames();
          if (pkColumnNames.hasNext()) {
            initialSortColumnName=pkColumnNames.next();
            initialSortAsc=true;
          }
        }
      }
 catch (      RepositoryException e) {
        Debug.log("String_Node_Str",e);
      }
    }
  }
  maxHeight=0;
  try {
    Iterator<IPersist> components=cellview.getAllObjects(PositionComparator.XY_PERSIST_COMPARATOR);
    while (components.hasNext()) {
      IPersist element=components.next();
      if (element instanceof Field || element instanceof GraphicalComponent) {
        if (element instanceof GraphicalComponent && ((GraphicalComponent)element).getLabelFor() != null) {
          labelsFor.put(((GraphicalComponent)element).getLabelFor(),element);
          continue;
        }
        Point l=((IFormElement)element).getLocation();
        if (l == null) {
          continue;
        }
        if (l.y >= startY && l.y < endY) {
          int height=((IFormElement)element).getSize().height;
          if (height > maxHeight)           maxHeight=height;
        }
      }
    }
    if (maxHeight == 0)     maxHeight=20;
  }
 catch (  Exception ex1) {
    Debug.error("String_Node_Str",ex1);
  }
  table=new WebCellBasedViewListView("String_Node_Str",data,1,cellview,dataProviderLookup,el,startY,endY,form);
  table.setReuseItems(true);
  add(table);
  final LinkedHashMap<String,IDataAdapter> dataadapters=new LinkedHashMap<String,IDataAdapter>();
  final SortedList<IPersist> columnTabSequence=new SortedList<IPersist>(TabSeqComparator.INSTANCE);
  createComponents(application,form,cellview,dataProviderLookup,el,startY,endY,new ItemAdd(){
    public void add(    IPersist element,    Component comp){
      if (element instanceof IFormElement && comp instanceof IComponent) {
        ((IComponent)comp).setLocation(((IFormElement)element).getLocation());
        ((IComponent)comp).setSize(((IFormElement)element).getSize());
      }
      elementToColumnIdentifierComponent.put(element,comp);
      if (cellview instanceof Form && element instanceof ISupportTabSeq && ((ISupportTabSeq)element).getTabSeq() >= 0) {
        columnTabSequence.add(element);
      }
      if (comp instanceof IDisplayData) {
        String dataprovider=((IDisplayData)comp).getDataProviderID();
        WebCellAdapter previous=(WebCellAdapter)dataadapters.get(dataprovider);
        if (previous == null) {
          WebCellAdapter wca=new WebCellAdapter(dataprovider,WebCellBasedView.this);
          dataadapters.put(dataprovider,wca);
        }
        if (dataprovider != null) {
          if (dataprovider.equals(initialSortColumnName))           initialSortedColumnId=comp.getId();
        }
      }
    }
  }
);
  for (int i=columnTabSequence.size() - 1; i >= 0; i--) {
    elementTabIndexes.put(columnTabSequence.get(i),Integer.valueOf(i));
  }
  if (addHeaders) {
    headers=new SortableCellViewHeaders(form,this,"String_Node_Str",table,cellview,application,initialSortedColumnId,initialSortAsc,new IHeaders(){
      public void registerHeader(      IPersist matchingElement,      Component headerComponent){
        SortableCellViewHeader sortableHeader=(SortableCellViewHeader)headerComponent;
        Component columnIdentifier=WebCellBasedView.this.elementToColumnIdentifierComponent.get(matchingElement);
        if (columnIdentifier instanceof IProviderStylePropertyChanges) {
          String width=(String)((IProviderStylePropertyChanges)columnIdentifier).getStylePropertyChanges().getChanges().get("String_Node_Str");
          if (width != null) {
            sortableHeader.setWidth(Integer.parseInt(width.substring(0,width.length() - 2)));
          }
 else           if (matchingElement instanceof BaseComponent)           sortableHeader.setWidth(((BaseComponent)matchingElement).getSize().width);
        }
        sortableHeader.setTabIndex(tabIndex);
        sortableHeader.setScriptExecuter(el);
        WebCellBasedView.this.registerHeader(matchingElement,headerComponent);
      }
    }
);
    add(headers);
  }
  if (useAJAX) {
    add(pagingNavigator=new ServoyAjaxPagingNavigator("String_Node_Str",table));
    add(new ServoyTableResizeBehavior(startY,endY,cellview));
  }
 else {
    add(pagingNavigator=new ServoySubmitPagingNavigator("String_Node_Str",table));
  }
  int scrollbars=0;
  if (cellview instanceof Portal) {
    scrollbars=((Portal)cellview).getScrollbars();
  }
  if (cellview instanceof Form) {
    scrollbars=((Form)cellview).getScrollbars();
  }
  showPageNavigator=!((scrollbars & ISupportScrollbars.VERTICAL_SCROLLBAR_NEVER) == ISupportScrollbars.VERTICAL_SCROLLBAR_NEVER);
  try {
    if (cellview instanceof Portal) {
      relationName=((Portal)cellview).getRelationName();
      Relation[] rels=application.getFlattenedSolution().getRelationSequence(((Portal)cellview).getRelationName());
      if (rels != null) {
        Relation r=rels[rels.length - 1];
        if (r != null) {
          defaultSort=((FoundSetManager)application.getFoundSetManager()).getSortColumns(application.getFoundSetManager().getTable(r.getForeignDataSource()),((Portal)cellview).getInitialSort());
        }
      }
    }
 else {
      defaultSort=((FoundSetManager)application.getFoundSetManager()).getSortColumns(((Form)cellview).getDataSource(),((Form)cellview).getInitialSort());
    }
  }
 catch (  RepositoryException e) {
    Debug.error(e);
    defaultSort=new ArrayList<SortColumn>(1);
  }
  try {
    dal=new DataAdapterList(application,dataProviderLookup,elementToColumnIdentifierComponent,el.getFormController(),dataadapters,null);
  }
 catch (  RepositoryException ex) {
    Debug.error(ex);
  }
}