我对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中使用消息框等待选项?
发布评论