是否可以在 GWT UiBinder 上下文中引用枚举
我有一个如下所示的枚举
public enum MyEnum {
A,
B;
}
然后我有一个带有自定义组件的 UiBinder 文件,该组件具有需要上面枚举的 setter 和 getter。 (我已经删除了“我可以引用我的枚举并将该值以任何方式放入 myAttribute 中吗?”的额外代码
<ui:UiBinder ....>
<g:HTMLPanel>
....
<myNamespace:myComponent myAttribute="" />
....
</g:HTMLPanel>
</ui:UiBinder>
?我想要完成的是这样的事情
<ui:UiBinder ....>
<ui:with field="myEnumField" type="com.example.MyEnum" />
<g:HTMLPanel>
....
<myNamespace:myComponent myAttribute="{myEnumField.A}" />
....
</g:HTMLPanel>
</ui:UiBinder>
但是似乎我不能用 ui:with 来做到这一点。我可以这样做吗这到底是什么?
I have an enumeration that looks like the following
public enum MyEnum {
A,
B;
}
And then I have a UiBinder file with a custom component that has a setter and getter expecting the enum above. (I've stripped the extra code for
<ui:UiBinder ....>
<g:HTMLPanel>
....
<myNamespace:myComponent myAttribute="" />
....
</g:HTMLPanel>
</ui:UiBinder>
Can I reference my enum and put that value into myAttribute in any way? What I want to accomplish is something like this
<ui:UiBinder ....>
<ui:with field="myEnumField" type="com.example.MyEnum" />
<g:HTMLPanel>
....
<myNamespace:myComponent myAttribute="{myEnumField.A}" />
....
</g:HTMLPanel>
</ui:UiBinder>
However it would seem that I cannot do this with ui:with. Can I do this in any way at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过更多搜索后,我意识到您实际上可以执行以下操作:
After searching a bit more I realized that you could actually do the following:
这是可能的。您应该能够直接将枚举传递给属性,例如,
MyComponent 小部件应该有一个接受 MyEnum 类型的 uiConstructor。
It is possible. You should be able to pass the enum to the attribute directly like,
The MyComponent widget should have a uiConstructor that accepts MyEnum type.