从另一个 Composite 调用 Composite 的 GWT 方法

发布于 2024-09-10 09:14:53 字数 364 浏览 2 评论 0 原文

我是 GWT 新手,正在尝试制作一个简单的应用程序(例如 fmylife 的小版本)。到目前为止,我制作了一个加载事实的组合,以及另一个具有提交新事实的表单的组合(这个组合有一个清除列表并再次填充的加载方法)。

我有一个按钮,当您按下它时,它会显示一个带有表单的窗口。 该表格用于添加新事实。但我想在正确添加事实后刷新主页并关闭此窗口。

我该怎么做?我应该将某种回调传递给窗口窗体吗?

编辑:我表达得不够好,WindowDialogBox rel="nofollow noreferrer">smartGWT

I'm new to GWT and trying to make a simple app (like a small version of fmylife). Up to now i made a composite that loads the facts and another composite that has a form to submit new facts (this one has a load method that clear the list and populate again).

I have a button that when you press it, it shows a Window with a form.
That form is used to add new Facts. But I want to refresh the main page when the Fact is added correctly and close this window.

How should I do this? Should I pass some kind of callback to the Window form?

Edit: I didn't express well enough, Window is a DialogBox provided by smartGWT.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夕嗳→ 2024-09-17 09:14:53

查看事件和事件总线

您还可以观看此视频以获得更好的解释。

Take a look at Events and the Event Bus.

You can also watch this video for a better explanation.

随风而去 2024-09-17 09:14:53

当然可以,为什么不呢?使用 onSave 等方法将回调传递给对话框中包含的组合。以这样一种方式设计流程,即对话框组合体始终编辑事实模型,并且不知道它是在创建新的事实模型还是编辑现有的事实模型。当用户提交弹出窗口时,让 DialogBox 使用回调调用 onSave。

将事实收集数据结构 CRUD 逻辑保留在 DialogBox 组合之外。

Sure, why not? Pass a callback with some method like onSave to the composite contained in the DialogBox. Design the flow in such a way that the DialogBox composite is always editing the fact model, and it it not be aware of whether it is creating a new fact model or editing an existing one. Let the DialogBox invoke onSave using the callback, when the user submits the popup.

Keep the fact collection data structure CRUD logic out of the DialogBox composite.

世界如花海般美丽 2024-09-17 09:14:53

您应该使用 对话框PopupPanel 而不是打开新窗口(大多数现代浏览器选择以任何一种方式打开新选项卡)。这样你就不会离开页面(这就是 AJAX 的全部意义,对吧?),你只需在其上覆盖一个新的 Widget,然后在“提交”时它将隐藏/销毁自身并添加一个新事实(无需重新加载整个页面)。

You should use DialogBox or PopupPanel instead of opening a new window (most modern browsers opt to open a new tab either way). That way you won't leave the page (that's the whole point of this AJAX thing, right?), you'll just overlay a new Widget over it and then on "submit" it will hide/destroy itself and add a new fact (without reloading the whole page).

木格 2024-09-17 09:14:53

同意上面的 DialogBoxPopupPanel 解决方案。但是,如果您仍然想使用 Window,可以考虑以下解决方案。

扩展Window并提供指向您想要返回的值的挂钩。然后,当您创建新的 CustomWindow 时,调用 addWindowCloseHandler 方法以在 CusomWindow 关闭时收到通知。在这种情况下,获取您需要的值并允许窗口关闭。然后进行异步调用来刷新主页。

Agreed with the DialogBox and PopupPanel solution above. However, if you'd still like to use Window, the following solution comes to mind.

Extend Window and provide hooks to the values you want back. Then, when you create the new CustomWindow, call the addWindowCloseHandler method to get notified when the CusomWindow is being closed. On that event, get the values you need and allow the window to close. Then make an async call to refresh your main page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文