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?
On TreeItem
there are 2 method setUserObject(Object userObject)
and getUserObject
. 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 a SelectionEvent
to the ValueChangeEvent
. You lose some information in between.