View Full Version : Duallist field and Event Listeners

21 Jul 2010, 8:29 PM

I am trying to capture the items being dragged between the from and to list fields in the duallist field control.

I am not able to track the proper event which would enable me to do so.

I had checked the API's but couldn't find anything.
Can anyone please point me to any helpful resource for the same ?

Thanks in advance.

21 Jul 2010, 10:52 PM

Rather than listening to the DualListField itself you should listen to its stores. Here's an example you could use on the TO-store:

toStore.addStoreListener(new StoreListener<MyModel>() {
public void storeAdd(StoreEvent<MyModel> se) {
ArrayList<MyModel> models = (ArrayList<MyModel>) se.getModels();


22 Jul 2010, 6:37 AM
Thanks for the quick reply.

I followed your suggestion and it seemed to solve my problem.

I tried to implement a storeRemove method as well to track items being removed from the toStore. However I found that the method was not getting invoked. Is the storeRemove method not the one that is to be used for my case above?

22 Jul 2010, 10:46 PM
The storeRemove should be correct - it's kinda hard to tell whats wrong here without any code ;)

If you could post a test case with an implemented EntryPoint that shows your problem, it would be a lot easier to help you.

24 Jul 2010, 12:25 AM
Sorry for the late update. I was trying a few more things to see if would work. I found out that the storeRemove method was being called

The following code

public void storeRemove(StoreEvent<BeanModel> se) {

would work and I would be able to remove items from the toListField

However if I modified the above code as below

public void storeRemove(StoreEvent<BeanModel> se) {
List<BeanModel> lst = se.getModels();
for(Iterator<BeanModel> iter=lst.iterator();iter.hasNext();)
BeanModel u = (BeanModel)iter.next();
//perform some operation


I would end up getting a javascript error c.e is null which pointed to one of the GWT generated cache html file.
After the error the duallist field would start misbehaving with the items not getting removed.

24 Jul 2010, 2:32 AM
I believe c.e refers to iter.hasNext() in the code.