• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

CommandLink ActionListeners in DataTable

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 J. Jackson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic