Gwt editor with not only getter/setter bean class

纵然是瞬间 提交于 2019-12-09 21:30:05

问题


Lets say I have form build in GWT, an UI-Binder, which implements Editor interface (com.google.gwt.editor.client.Editor) with two date fields (date from and to). Bean class is expected to have members:

    Date fromDate; // with getter and setter
    Date toDate;   // with getter and setter

And okay, while having bean class defined as written, there is no problem, but just after I add something like this:

public boolean hasFromDate()
{
    return fromDate != null;
}

I got compilation error (for example for fromDate):

 [ERROR] Line 17: The method hasFromDate() is undefined for the type Date
 [ERROR] Line 20: The method setFromDate(Date) is undefined for the type Date

The generated code in temporary file (qualifiedBeanClass_fromDate_Context.java) appears to have:

@Override public java.util.Date getFromModel() {
    return (parent != null && true) ? parent.getToDate().hasToDate() : null;
}

@Override public void setInModel(java.util.Date data) {
    parent.getToDate().setToDate(data);
}

Where parent is my bean class. This is terribly wrong, cause getToDate() returns Date (or null) instance, so there is absolutely nothing wrong about the compilation error. Problem is, why GWT cares about those methods (hasToDate/hasFromDate) or is it a mandatory to have only getter/setter methods?

来源:https://stackoverflow.com/questions/28719713/gwt-editor-with-not-only-getter-setter-bean-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!