• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Find "who triggered" from actionListener

 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Im using a dataTable in which I created several components.
One of the component is a Button with different display value for each row.

However, all my buttons are set with the same id and actionListener.
How can I know which button was pushed by the user ?



Lets say that my *myBean.myVendors* collection contains 4 entries : 4 buttons will be created and I would like to know which one was hit in my listener.

How can I do that ? I tried a whole bunch of stuff, looked at every property in debug... nothing will do. The value of my buttons are all diferrent though, but I can't access this property.

I'm certainly missing something big...

If anyone can help me, it would be appreciated.

Thanks,
Alex
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must be having the event object in the listener. Call getComponent() method on the event object to get the UIComponent. Once you get the hadnle of this UIComponent, you can easily find out which component by clicked. Check the api to see which all methods you can use.
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

both, no matter what property I access via getComponent, all my buttons have the same value.

I want to know which button from which row was hit...

Do you see what I mean ?

Thanks,
Alex
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to take a look at this thread.
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I saw your post, but the answers seem to talk about something else.

I cant believe there is no way to know which row was selected !

Or no way to dynamically set different id for each of my buttons.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alex Turcot:
Hi,

both, no matter what property I access via getComponent, all my buttons have the same value.

I want to know which button from which row was hit...

Do you see what I mean ?

Thanks,
Alex


Does all the component have same id? That isn't possible else you would get "Duplicate Component Id", anyways I believe in your scenario those id wont be of any help as they are normally like id_27 etc. which cant help much.

Now as Gregg pointed, table.getRowData() method returns the selected row in the data table. This way you can find out the index of selected row and hence the buton which was clicked.
That can help you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic