如何在vaadin中使用消息框等待选项?

编程入门 行业动态 更新时间:2024-10-20 20:43:58
本文介绍了如何在vaadin中使用消息框等待选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我对Vaadin和Web应用程序并不陌生.我在使用Vaadin附加Steinwedel从MessageBox获取选择的选项时遇到问题(简单的是或否).

I'm little new to Vaadin and web applications. I'm having problems getting the selected option (a simple yes or no) from a MessageBox with Vaadin add-on Steinwedel.

我需要等待客户端说是"或否",然后像在Java JOption中那样为该选项运行我的代码.我有一个MessageBox的类,该类返回该选项:

I need to wait for the client to say "yes" or "no", then run my code for that option, as in java JOption. I have a class for MessageBox that returns the option:

int option = MessageBox.showDialog (message, title, QUESTION_YES_NO_OPTION);

但是,即使我打开了MessageBox,我的代码也始终运行着.

But my code always runs through, even though I have my MessageBox opened.

推荐答案

与传统的桌面GUI框架(如Swing)不同,使用Vaadin,您主要在服务器端进行编程,并从客户端监听事件(浏览器与用户一起浏览)相互作用).因此,显示对话框不会阻塞服务器端代码,因为不会发送来自客户端的(HTTP)请求的答案.相反,您应该显示对话框并听取对话框按钮的单击事件.

Unlike in a traditional desktop GUI framework such as Swing, with Vaadin you are programming primarily on the server side and listen to events from the client side (browser with user interaction). So, showing a dialog does not block on the server side code because the answer to the (HTTP) request that came from client wouldn't be sent. Instead you should show the dialog and listen to the click events of the dialog buttons.

MessageBox .createInfo() .withCaption("Info") .withMessage("Hello World!") .withOkButton(() -> System.out.println("Ok pressed.")) .open();

该示例摘自附加说明.在这里,他们使用println处理了OK按钮.

The example is taken from the add-on description. Here they handled the OK-button click with a println.

更多推荐

如何在vaadin中使用消息框等待选项?

本文发布于:2023-11-23 19:52:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项   消息   如何在   vaadin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!