2 single selection tables on the same page

I used the following great article:

http://blogs.sun.com/roller/page/winston?entry=single_selectable_row_table_comp onent

to create a singlerow select table. But I want 2 of these tables on the same page of my tabset component.

On my page i have:

private TableSelectPhaseListener tablePhaseListener = new TableSelectPhaseListener();

public void setSelected(Object object) {

RowKey rowKey = (RowKey)getValue("#{currentRow.tableRow}");

if (rowKey != null) {

tablePhaseListener.setSelected(rowKey, object);

}

}

public Object getSelected(){

RowKey rowKey = (RowKey)getValue("#{currentRow.tableRow}");

return tablePhaseListener.getSelected(rowKey);

}

public Object getSelectedValue() {

RowKey rowKey = (RowKey)getValue("#{currentRow.tableRow}");

return (rowKey != null) ? rowKey.getRowId() : null;

}

public boolean getSelectedState() {

RowKey rowKey = (RowKey)getValue("#{currentRow.tableRow}");

return tablePhaseListener.isSelected(rowKey);

}

but when I added the second table, I had to add the duplicate the above 4 methods, changing currentRow to currentRow2 and tablePhaseListener to tablePhaseListener2, and changing the method names. I also had to make these updates in 2 other placeson the JSP code, as well as in the JavaScript!! For just 2 tables this isn't too bad, but with more tables having to synchronize everything could get real ugly real fast. Am I doing something wrong?

Also,

It seems to work, however my IE browser is still reporting some minor Javascript errors that I don't get when I had only 1 single-row select table

Thanks,

-DM

[1720 byte] By [mazzared] at [2007-11-26 9:03:48]
# 1

I also went the route of duplicating all methods for the single-selectable row in a table.

I have at most on my pages two tables with selectable rows and I have not run into any javascript issues.

I have had a problem when I rename my tables from "table1" etc. The row selection does not work as well when I give my table objects meaningful names. I have not had the time to dig in and discover why.

Rebecca_H at 2007-7-6 23:13:28 > top of Java-index,Development Tools,Java Tools...