问题描述
我正在使用 gwt uibinder.我想动态地为一个字段设置值.我正在尝试这样的事情
I am using gwt uibinder. I want to dynamically set values to a field.I am trying something like this
<ui:with field="valuesStore" type='x.y.client.ValuesStore' />
并且该字段设置为这样的值
and the field is set with value like this
<g:Label text='{valuesStore.getValue}'>Name</g:Label>
ValueStore 有两种方法
and the ValueStore has 2 methods
public String getValue(String key) {
return localizedValues.get(key);
}
public String getValue() {
return null;
}
问题是我无法调用 getValue(key).我只能调用 no-args 方法,这意味着以下是不可能的
The problem is i am unable to call the getValue(key). I could only call the no-args method meaning the following is not possible
<g:Label text='{valuesStore.getValue('name')}'>Name</g:Label>
请说明是否有办法实现这一点,我可以通过传递给它的参数调用方法.
Please clarify if there is a way to achieve this where i can call a method with arguments passed to it.
推荐答案
不支持,只能调用没有参数的方法.您将不得不将 name
直接公开为无参数方法.
That is not supported, only methods without arguments can be invoked. You are going to have to expose the name
directly as a no args method.
查看FieldReferenceConverter,这描述了使用的语法.可以看到不支持参数传递.
Look at the documentation for FieldReferenceConverter, this describes the syntax used. You can see that there is no support for argument passing.
这篇关于gwt uibinder ui:with - 使用参数调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!