| Author |
CommandLink ActionListeners in DataTable
|
Jack J. Jackson
Greenhorn
Joined: Apr 20, 2002
Posts: 27
|
|
I'm using Sun RI 1.1_01 and MyFaces Tomahawk 1.1.1. Inside a DataTable, I have a CommandLink that appears on each row of data. The CommandLink has an ActionListener bound to a method on a session-scoped bean. Each row has the same client Id. I just discovered that the ActionListener is fired for every row in the data table; i.e. if there are 100 rows, the actionListener method is invoked 100 times. I'm not sure why this would ever be useful behavior; it certainly isn't for my application. Why does the actionListener event get fired for each row in the table? Is it because each row has the same id? I suspect I've configured something incorrectly and would appreciate being steered back on course. Thanks.
|
Jack
|
 |
Jack J. Jackson
Greenhorn
Joined: Apr 20, 2002
Posts: 27
|
|
I'm adding more info to my original post. The following are the artifacts needed to illustrate what I'm talking about: - faces-config.xml entry - SimpleItemContainer - OrderableItem - simpleList.jsp form element When a link in a row is clicked, the actionListener method (simpleItemContainer.listener) is fired 10 times. Here's the output after clicking a link: What I'd like to have happen is have the actionListener method "consume" the event so it's not broadcast 9 times more than is needed. Since this issue hasn't been raised, I'm sure I've just misconfigured something. (or am doing this all wrong!) Thanks for any help. [ March 15, 2006: Message edited by: Jack J. Jackson ] [ March 15, 2006: Message edited by: Jack J. Jackson ]
|
 |
Jack J. Jackson
Greenhorn
Joined: Apr 20, 2002
Posts: 27
|
|
Okay. I found the cause of the problem. I was using a MyFaces HtmlDataTable, but a Sun RI HtmlCommandLink was enclosed in a row. Apparently unique ids were not being generated for each row, causing every CommandLink's actionListener to be fired when any CommandLink was clicked. When I switched the DataTable back to RI from MyFaces, a unique id is generated for each row's CommandLink. I wanted to use the MyFaces "rowindex" attribute. Maybe if I used the MyFaces JSF impl, things would work, but I'm mandated to use the Sun JSF RI implementation. Oh well.
|
 |
 |
|
|
subject: CommandLink ActionListeners in DataTable
|
|
|