So I have a custom SingleSelectionModel which I am using to catch the 
setSelection well before it is selected. Basically to Cancel selection of 
second cell if the form data of the first cell is not saved. 

public class PromptingSelectionModel<T> extends SingleSelectionModel<T> {

    private boolean stopSelection;

    public PromptingSelectionModel() {

        super();

    }

    public PromptingSelectionModel(ProvidesKey<T> keyProvider) {

        super(keyProvider);

    }

    @Override

    public void setSelected(T object, boolean selected) {

        if (formChanged

                && !Window.confirm("There are unsaved changes, are you sure 
you want to continue?")) {

            stopSelection = true;

            return;

        } else {

            stopSelection = false;

        }

        if (!(stopSelection)) {

            super.setSelected(object, selected);

          }

    }

 The problem I see here is When I move from one Cell item to another the 
setSelected method here is sometimes called twice and sometimes it is 
called once. 

Cell 1 selected. Which shows form data. I changed form data. formChanged 
get set to True. 

Clicked on Cell 3. setSelected method of PromptingSelectionModel is called. 
I see parameters to the methods are coming as DTO of Cell 1 and false. I 
get the confirm dialog box. I clicked Cancel. setSelected method of 
PromptingSelectionModel is called again. I see parameters to the methods 
are coming as DTO of Cell 2 and true.  I get the confirm dialog box again. 
Clicking Cancel now will keep the selection of Cell 1. So I got two confirm 
here okay? Then I click Cell 5. setSelected method of 
PromptingSelectionModel is called. I see parameters to the methods are 
coming as DTO of Cell 5 and true.I get the confirm dialog box only once. 
Clicking Cancel now will keep the selection of Cell 1.

Is this a know bug? It seems internally hasCellPresenter class is called or 
something which sets the second cell as true. 





-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to