kohiro / gwt-ent

Automatically exported from code.google.com/p/gwt-ent
0 stars 0 forks source link

getPropertyNames method of ModelDataAdapter always null #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Old code:

public Collection<String> getPropertyNames() {
    if (propertyNames != null) {
      Collection<String> result = new ArrayList<String>();
      for (Method method : classType.getMethods()) {
        if ((method.getName().startsWith("get"))
            && (method.getParameters().length <= 0)) {
          result.add(method.getName().substring(4));
        }
      }
    }
    return propertyNames;
  }

This method will always return null because propertyNames is set to be null 
as default thus never entering the loop. Also once it's in the loop the 
variable never gets set.

Fixed code:

  public Collection<String> getPropertyNames() {
    if (propertyNames == null) {
      Collection<String> result = new ArrayList<String>();
      for (Method method : classType.getMethods()) {
        if ((method.getName().startsWith("get"))
            && (method.getParameters().length <= 0)) {
          result.add(method.getName().substring(4));
        }
      }
      propertyNames = result;
    }
    return propertyNames;
  }

Original issue reported on code.google.com by b.nwi...@gmail.com on 6 Oct 2009 at 12:32

GoogleCodeExporter commented 9 years ago
FYI class is com.gwtent.client.uibinder.gxt.model.ModelDataAdapter

Original comment by b.nwi...@gmail.com on 6 Oct 2009 at 12:33

GoogleCodeExporter commented 9 years ago
Also the substring method should start at index 3 not 4

Original comment by b.nwi...@gmail.com on 6 Oct 2009 at 12:50

GoogleCodeExporter commented 9 years ago
Thank you very much, fixed

Original comment by JamesLuo...@gmail.com on 18 May 2010 at 4:56