具有 I18N GWT 的 TreeItem
我想知道如何使用 I18N 构建 TreeItem 并且菜单项没有不同的标记。
如果我像这样构建一个 TreeItem:
@UiField
Tree tree;
TreeItem customer = new TreeItem(customerGroup");
customer.addItem("searchCustomer");
customer.addItem("create");
customer.setState(true);
tree.clear();
tree.addItem(customer);
@UiHandler("tree")
public void onSelection(SelectionEvent<TreeItem> event) {
eventBus.fireEvent(event);
}
当用户单击“创建”节点时获得的 ValueChange 标记是“创建”,然后我得到如下代码
public void onValueChange(ValueChangeEvent<String> event) {
String token = event.getValue();
if(token.equals("create")
{
CreateCustomerView create = new CreateCustomerView(eventBus,
customerService);
content.setContent(create);
}
...
但是如果我想在 TreeItem 节点中使用不同的语言怎么办?我想要除文本之外的其他东西作为令牌,也许是一个 id。我可以使用 MVP 模式中的 Places 模式来解决这个问题吗?如果可以的话,它是如何工作的?
I am wondering how to build a TreeItem with I18N and not have different tokens for a menu item.
If I build a TreeItem like this:
@UiField
Tree tree;
TreeItem customer = new TreeItem(customerGroup");
customer.addItem("searchCustomer");
customer.addItem("create");
customer.setState(true);
tree.clear();
tree.addItem(customer);
@UiHandler("tree")
public void onSelection(SelectionEvent<TreeItem> event) {
eventBus.fireEvent(event);
}
the ValueChange token I get when a user clicks the "create" node is "create" and then I get code like
public void onValueChange(ValueChangeEvent<String> event) {
String token = event.getValue();
if(token.equals("create")
{
CreateCustomerView create = new CreateCustomerView(eventBus,
customerService);
content.setContent(create);
}
...
But what if I want to have different languages in the TreeItem nodes, then I want something other then the text as a token, perhaps an id. Can I solve this with the Places pattern from the MVP pattern, and if so how does that work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
TreeItem
上有2个方法setUserObject(Object userObject)
和getUserObject
。您可以使用它们或设置一个 Id,然后您可以用它来检查。但是,我不明白您如何从SelectionEvent
转到ValueChangeEvent
。您会在两者之间丢失一些信息。On
TreeItem
there are 2 methodsetUserObject(Object userObject)
andgetUserObject
. You can use those to or set an Id, which you than can use to check against. However, I don't see how you come from aSelectionEvent
to theValueChangeEvent
. You lose some information in between.为什么不将附加到
SelectionEvent
的所选项目与您之前添加的项目进行比较?像这样的:或者我错过了什么?
Why don't you compare the selected item attached to the
SelectionEvent
with the items you added previously? Something like this:Or am I missing something?