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.
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; }
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
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.