2
我对如何使用GWT的ValueListBox和编辑器感到困惑。我得到这个错误:GWT ValueListBox编辑器
The method setValue(String) in the type TakesValueEditor<String>
is not applicable for the arguments (List<String>)
这是相关的代码。
public class MyBean {
private List<String> dateFormats;
public List<String> getDateFormats() {
return dateFormats;
}
public void setDateFormats(List<String> dateFormats) {
this.dateFormats = dateFormats;
}
}
public interface MyBeanView extends IsWidget, Editor<MyBean> {
@Path("dateFormats")
IsEditor<TakesValueEditor<String>> getDateFormatEditor();
}
public class MyBeanViewImpl implements MyBeanView {
@UiField(provided=true) ValueListBox<String> dateFormats;
public MyBeanViewImpl() {
dateFormats = new ValueListBox<String>(PassthroughRenderer.instance(),
new ProvidesKey<String>() {
@Override
public Object getKey(String item) {
return item;
}
});
dateFormats.setAcceptableValues(Arrays.asList(new String[] {"YYYY"}));
// ... binder.createAndBindUi(this);
}
@Override
public IsEditor<TakesValueEditor<String>> getDateFormatEditor() {
return dateFormats;
}
}
这里有什么用的xmlns ui.xml:G = '瓮:进口:com.google.gwt.user.client.ui'>
<g:HTMLPanel>
Data Formats: <g:ValueListBox ui:field="dateFormats"> </g:ValueListBox>
</g:HTMLPanel>
我肯定缺少明显的东西这里。非常感谢。
感谢BobV做了一些烦人而又必要的工作,指出后见之明。 – Glenn 2011-05-06 23:17:01
'MyBean'应该只有一个字段'String dateFormat'吗?而编辑器只有一个字段'ValueListBox dateFormat'。它会让我看到更正后的代码..谢谢! –
2018-01-19 08:17:25