Question

My Question:

In the code below I try to ask user a value. SC.askforValue() is called with all possible variables, a Dialog is given as parameter to adjust the dialog.

My problem is what happens, when user presses cancel? On my current smartGwt version (2.1), is it possible to see the cancel alone? Now empty value and cancel get both handled in the same way.

My Code:

Dialog dialog = new Dialog();
dialog.setWidth(200);

SC.askforValue("myTitle", "myQuestion", "defaultValue", new ValueCallback() {

   @Override
   public void execute(String value) {
        if (value != null) {
        // do sth.
        } else {
        /* cancel pressed / empty value. */
        }
       }
}, dialog);
Was it helpful?

Solution

As per the documentation,

if you want to differantiate blank input and cancel event, you can check the value, you receive in the callback. When user has entered nothing and clicks OK, blank string will be there as value. And when user clicks Cancel, the value will be null.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top