UiBinder 与 ToggleButton 配合使用

发布于 2024-08-15 10:12:47 字数 302 浏览 3 评论 0原文

我喜欢新的 GWT2 UiBinder,但是,尚不清楚使用声明式 UI 风格是否可以实现某些功能。

例如,ToggleButton 仅在构造时获取图像实例(没有向上/向下图像的设置器)。据我了解,UiBinder 以类似 JavaBean 的反射方式工作,其中可分配的属性被映射到相应的 setter。这种样式是否可以用于像 ToggleButton 这样的小部件,其中某些属性必须在构造时指定?

<g:ToggleButton ui:field="myBtn"></g:ToggleButton>

I'm liking the new GWT2 UiBinder, however, it's not clear whether certain things are achievable using the declarative UI style.

For instance, ToggleButton only takes the image instances at construction time (no setters for up/down images). As I understand, UiBinder works in a JavaBean-like reflective way, where the assignable attributes are mapped to corresponding setters. Is this style possible with widgets like ToggleButton, where certain attributes have to be specified at construction time?

<g:ToggleButton ui:field="myBtn"></g:ToggleButton>

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

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

发布评论

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

评论(3

强辩 2024-08-22 10:12:47

@马特·莫里亚蒂:谢谢你的提示!我发现我必须这样做:

<g:ToggleButton ui:field="foo">
    <g:upFace><img src="images/bar.png"/></g:upFace>
</g:ToggleButton>

如果您不指定其他面(例如 downFace),则该图像将用于所有按钮状态。

编辑:我猜您在正式指定 external 时使用 ui:image资源

@Matt Moriarity: Thanks for the tip! I found I had to do it like this:

<g:ToggleButton ui:field="foo">
    <g:upFace><img src="images/bar.png"/></g:upFace>
</g:ToggleButton>

If you don't specify other faces (e.g. downFace), that image is used for all button states.

Edit: I guess you use ui:image when you're formally specifying external resources?

情愿 2024-08-22 10:12:47

您可以使用 @UiFactory 或使用 @UiField(provided=true) 提供这些小部件来创建这些小部件,

请参阅http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Using_a_widget

You can create these widgets using a @UiFactory or by providing it using @UiField(provided=true)

See http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Using_a_widget

忘羡 2024-08-22 10:12:47

尝试这样的事情:

<g:ToggleButton>
  <ui:image src="..." />
</g:ToggleButton>

Try something like this:

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