Selik
Selik

Reputation: 71

GWT. How to handle two similar actions with one event?

I've encountered next problem. I've got list of products and each product has button to open its QuickLook PopUp. I've created special event for this button, registered it in EventBus and trigger them. Everything seems good, but when I click one button, popup is shown not just for this item, but for all items, that are in list (I mean numbers of that "show"). This happens cause I have one Event-class for all these buttons, but can I somehow separate them one from another?

I just want to set some ID or something like that to every button and check this condition while triggering or (this would be even better) trigger only event, that I really need.

Upvotes: 1

Views: 102

Answers (2)

udalmik
udalmik

Reputation: 7988

You can add productId to your Custom Event as a property. Event handler will check it and show only required product info.

Upvotes: 0

Andrei Volgin
Andrei Volgin

Reputation: 41089

You don't need an EventBus for this. You can create a simple ClickHandler and attach it to your buttons. When you create a ClickHandler, you pass a product ID (or whatever you use to differentiate your products) to a method that shows your popup.

Upvotes: 2

Related Questions