将组件附加到面板并将其渲染在屏幕上的更有效方法

发布于 2024-09-28 12:44:00 字数 407 浏览 0 评论 0原文

他的,

我尽可能使用 UiBinder 来提高应用程序性能。然而,据我了解,当相应模板包含静态信息丢失时,UiBinder 处于最佳状态。

就我而言,移动应用程序的大部分屏幕区域都包含动态信息。例如,有一个带有按钮的面板,但您事先不知道一次显示多少个按钮。这就是为什么我在所属的 UiBinder 类中使用 HTMLPanel.add(Widget wgt, String id) 或 FlowPanel.add() 方法。这是否会减少 UiBinder 的使用以及调用 setInnerHTML() 而不是通过 DOM 操作创建元素的能力,因为这些 add() 方法只接受小部件而不接受元素?

也许有一个技巧可以允许将 Element 对象而不是 Widget 对象添加到面板中,然后他们将充分使用 setInnerHTML ?

谢谢

His,

I am using UiBinder whenever possible to improve application performance when possible. However, as far as I understand, UiBinder is at its best when corresponding template contains losts of static information.

In my case, mobile app, most of the screen areas contain dynamic information. For instance, there is a panel with buttons, but you dont know ahead of time how many buttons are shown at a single time. That is why I am using HTMLPanel.add(Widget wgt, String id) or FlowPanel.add() methods in the owning UiBinder class. Isnt that diminishes use of UiBinder and ablility to call setInnerHTML() instead of creating elements trough DOM operations because these add() methods only accept widgets and not elements?

Maybe there is a trick which would allow to add Element object instead of Widget objects to panels and they would then use setInnerHTML to its fullest?

Thanks

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

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

发布评论

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

评论(1

别闹i 2024-10-05 12:44:00

在某些情况下(不幸的是,由于 IE,排除了按钮),您可以只添加 DOM 元素和/或使用innerHTML(在 DOM 元素上,在这种情况下不要使用面板小部件)并侦听更高级别的事件(通常是您的UiBinder 所有者小部件),利用事件冒泡。换句话说:使用通常所说的“事件委托”。

In some cases (which unfortunately exclude buttons, because of IE), you can just add DOM elements and/or use innerHTML (on DOM elements, do not use panel widgets in this case) and listen to events at a higher level (generally your UiBinder owner widget), taking advantage of event bubbling. In other words: use what's generally called "event delegation".

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