GWT 2.1 UiBinder SimplePager 需要位置属性
可以为我尝试过 CENTER 的位置属性提供什么
<c:SimplePager ui:field='pager' location='HERE' />
,但它不起作用,我在费用示例应用程序中看到它们没有位置属性,而是在 UiBinder 中创建它时设置它。但我不能这样做,因为它是必需的属性。 该怎么办?
What can be provided to the location attribute of a
<c:SimplePager ui:field='pager' location='HERE' />
I tryed CENTER, but it didnt work, I see in the expense sample app that they dont have a location attribute but instead set it on the creation of it in the UiBinder. But I cant do that since its a required attribute.
What to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须提供
SimplePager.TextLocation
,可以是 CENTER、LEFT 或 RIGHT。You must provide
SimplePager.TextLocation
, which can be CENTER, LEFT or RIGHT.目前我看到的唯一解决方案是使用
@UiField(provided = true)
。不确定这是否有任何帮助,但无论如何请查看下面的小示例。ui.xml:
和小部件:
The only solution I see at the moment is working with
@UiField(provided = true)
. Not sure if that is of any help but check out the small example below anyway.The ui.xml:
and the widget:
SimplePager 类无法由 UiBinder 实例化,因为它没有 Location 的 setter 来修复错误。
@UiField(provided=true) 的替代方案允许自动实例化变量,方法是创建一个工厂方法来指示 UiBinder 外部的页面如何实例化以及在需要时设置对象。
下面是工厂方法的示例,它将应用于任何 @UiField SimplePager 类。 @UiField(provided=true) 将处理多个不同的实例化,但对于一个 UiFactory 来说是最简单的,因为您不必关心何时使用变量。
The SimplePager class can't be instantiated by UiBinder, because it doesn't have a setter for Location to fix the error.
An alternative to @UiField(provided=true), which allows the variable to be instantiated automatically is by creating a factory method to instruct the page outside of UiBinder on how to instantiate and if needed setup the object.
Here's an example of the factory method it will apply to any @UiField SimplePager class. @UiField(provided=true) would handle multiple varying instantiations, but for one UiFactory is the simplest, because you don't have to be concerned with when the variable is used.