Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何处理Smart gwt SC.askforValue()cancel?_Java_Gwt_Smartgwt - Fatal编程技术网

Java 如何处理Smart gwt SC.askforValue()cancel?

Java 如何处理Smart gwt SC.askforValue()cancel?,java,gwt,smartgwt,Java,Gwt,Smartgwt,我的问题: 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. } el

我的问题:

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);
在下面的代码中,我尝试向用户询问一个值
SC.askforValue()
与所有可能的变量一起调用,给出一个
对话框作为参数来调整对话框

我的问题是,当用户按下“取消”时会发生什么?在我当前的smartGwt版本(2.1)上,是否可以单独看到取消?现在,空值和取消以相同的方式处理

我的代码:

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);
根据,


如果要区分空白输入和取消事件,可以检查回调中接收的值。当用户未输入任何内容并单击“确定”时,空白字符串将作为值出现。当用户单击Cancel时,该值将为null。

我在Dialog的API上看到,有一个cancelClick()可以被覆盖,但是需要哪种代码?在这种情况下,可能还需要重写okClick()。。那么这与回调有什么关系呢?这是解决方案路径上的棘手部分。覆盖“单击”对话框没有帮助,回调无论如何都会执行。我想知道对话框上按下了哪个按钮,但仍然不知道如何…我有一个较旧版本的smart,已经有了4.0,我们有2.1。当然,在我们的例子中,空字符串的返回值也是null。如果没有其他解决方案出现,我会接受这一点,因为添加了此注释的隐式解决方案是,我必须更新我的smart以获得正确的结果。