This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 99822 - Table Row group iterator not iterating through columns
Summary: Table Row group iterator not iterating through columns
Status: CLOSED INVALID
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: Winston Prakash
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-03 14:24 UTC by ciappie
Modified: 2007-04-24 09:08 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ciappie 2007-04-03 14:24:00 UTC
I am extending the JSF table component to perform edit operations and I need 
to iterate through the columns of my table to get the column components and 
set the textfield etc to readonly = false so that the user can edit that 
particularly selected row.

In the edit button action even I am iterating through the columns one by one 
to get their children.

The TableRowgroup iterator is all the time giving me the same column and goes 
into an infinite loop.

Below is my code. When I see the value of the id in string s it is always the 
same values 'TableColumn8'. 

I pretty much think that this is a bug in the TableRowgroup iterator.

public String btnEdit_action() {
        try{ 
            RowKey[] selectedRowKeys = getTableRowGroup1().getSelectedRowKeys
();
            TableRowGroup tbrg = getTableRowGroup1();
            String s = new String ();
            
            for(int i=0; i< selectedRowKeys.length; i++){
                int rowId = Integer.parseInt(selectedRowKeys[i].getRowId()) + 
1;
                 cachedRowSetDataProvider1.setCursorRow(selectedRowKeys[i]);
                 tbrg.setRowKey(selectedRowKeys[i]);   
                 while (tbrg.getChildren().iterator().hasNext()){
                     //s = tbrg.getChildren().iterator().next().getChildren
().iterator().next().getId();
                     s = tbrg.getChildren().iterator().next().getId();
                     tbrg.getChildren().iterator(). next();
                 }
           }
            btnEdit.setText(new String("Save"));
        
        }
        catch (Exception e) {
           log ("Cannot delete record " + e.getMessage()) ;
           error ("Cannot delete record " + e.getMessage()) ;
        }
        return null;
    }
Comment 1 Winston Prakash 2007-04-24 01:08:43 UTC
This is user error. The iterator is obtained indefinitely. The code should be

    Iterator iter = tbrg.getChildren();
    while (iter.hasNext()){    
        s = ((TableColumn)iter.next()).getId();
    }

To verify

- Add a Table Component
- Add a button
- Add a Message group
- Double click the button and add the code
   public String button1_action() {
        TableRowGroup tbrg = getTableRowGroup1();
        Iterator iter = tbrg.getChildren().iterator();
        while (iter.hasNext()){
            info(((TableColumn)iter.next()).getId());
        }
        return null;
    }

Deploy the application and click on the button. The message group should print
TableColumn1, TableColumn2, TableColumn3
Comment 2 ciappie 2007-04-24 09:08:54 UTC
I never realised I have to create a seperate instance on the Iterator and 
initialise it with the tablerowgroup children. I was assuming that I can use 
the tableRowGroup iterator itself.