0
votes

I'm writing a messaging application in GWT, and have a fairly difficult problem to find a solution for. I'm working with a GWT CellList. In my cell list I'm displaying all the recent contacts a user has had recent communication with. But lets say that a user is writing a message to a person not on that list. I temporarily add them to the recentContacts list, and update the CellList so that it shows..

But then let's say that they end up not sending the message. I need to be able to detect that, and remove them from the list. The obvious place to do that is in the selection change handler. It actually turns out though that within a selection change handler, if can modify the list of data objects that represent the cell list, but when you actually push them to the cell list, I get an index out of bounds error.

I've verified that this is the issue. So basically I'm stuck. The obvious place to check this is when your selecting a different contact to view. I can then check if any messages were sent to this other contact, and if not, get rid of the contact, but I need to somehow not do it in the selectionChangeHandler. Does anyone have any solution/ideas? I tried a mouse up event, but that ends up happening before the selection event takes place.

Thanks for any help in advance :-)

selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            ContactDO selectedContact = selectionModel.getSelectedObject();

            //Check if we want to remove a contact from the list
            if ( we want to remove a contact in the list that is not the currently selected contact. ) {

                 //remove contact
                 recentContacts.remove(contactThatisNotSelected);

                 //Refresh the contact cell list
                 contactCellList.setVisibleRange(0, recentContacts.size());
                 contactCellList.setRowCount(recentContacts.size(), true);
                 contactCellList.setRowData(0, recentContacts);
            }


        }
    });
1
When does the index out of bounds occur? If it's inside GWT code it sounds like a bug. Did you check the issue tracker for that?Ümit
No, but I did plenty of searches, and normally something comes up under the issue tracker if there is something for that. It seems that before the selection event the code is recording, or taking note of the size of the list, and it's expecting it to be the same afterwards. I band-aid fixed it by using a timer that does the logic 100ms later.spierce7

1 Answers

0
votes

The solution that I implemented was just to use a Timer, and then do the work about 100ms later. Not really a fan of this solution. I'm still looking for another.