Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DSResponse data is expected to be an array of ListGridRecords. This allows the data

    Hi

    After upgrade to Smart GWT 5.0, we experience warning message "DSResponse data is expected to be an array of ListGridRecords. This allows the data to be displayed as expected in ListGrids bound to this dataSource."
    Has to be DataSource always bound only to ListGrid? I guess not, what about option DataSource for select items or DataSource used for forms.

    DSResponse.setData() has method argument of type Record[], but providing array of Record will always show warning message ... then why you rather don't force users to provide argument of type ListGridRecord[]?

    DSResponse.getData() return type is Record[]. So it is not possible to use DSResponse.setData(DSResponse.getData()) without warning.

    Can you please defend your intention behind the warning message?
    Thanks
    Matus
    Last edited by matus_b; 13 Apr 2015, 08:21. Reason: Message not complete in the title

    #2
    This is motivated by some obscure issues with Java typing and GWT. We kept the signature the same to avoid a required code change, although you should, as the warning message tells you, go ahead and update your code.

    Comment


      #3
      If you are expecting by default to use ListGridRecord instead of Record, then why don't you provide new methods?

      Code:
      public class Test {
          public static void main(String[] args) {
              new Test();
          };
      
          private Test() {
              Record[] records = new Record[] {};
              ListGridRecord[] listGridRecords = new ListGridRecord[] {};
      
              // warning
              setData(records);
      
              // no warning
              setData(listGridRecords);
      
              // no warning
              setData(getData());
      
              // no warning
              records = getData();
              setData(records);
          }
      
          public void setData(Record[] a) {
              if (a instanceof ListGridRecord[]) {
                  System.out.println("setData(Record[] a) redirecting to setData(ListGridRecord[] b)");
                  setData((ListGridRecord[]) a);
              } else {
                  System.out.println("WARNING: setData(Record[] a)");
                  System.out.println("set data attribute");
              }
          }
      
          public void setData(ListGridRecord[] b) {
              System.out.println("setData(ListGridRecord[] b)");
              System.out.println("set data attribute");
          }
      
          public ListGridRecord[] getData() {
              System.out.println("getData()");
              return new ListGridRecord[] {};
          }
      
          private class Record {
          }
      
          private class ListGridRecord extends Record {
          }
      }
      Output:
      Code:
      WARNING: setData(Record[] a)
      set data attribute
      setData(ListGridRecord[] b)
      set data attribute
      getData()
      setData(ListGridRecord[] b)
      set data attribute
      getData()
      setData(Record[] a) redirecting to setData(ListGridRecord[] b)
      setData(ListGridRecord[] b)
      set data attribute
      Anyway, DSResponse expecting data to be always ListGridRecord array makes no sense because DataSource it's not meant only for ListGrids.

      Comment


        #4
        Again, the underlying problem is some obscure issues with Java typing and GWT. Our solution was the best of available options, and his little to no impact on developers.

        Comment


          #5
          Best maybe but not smart for sure. At least you can put some documentation about the issue.

          Comment

          Working...
          X