Announcement

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

    listgrid fetchdata doesn't populate grid when there are errors in dsresponse

    Hello,

    OK, so i have the following usecase: i have a listgrid for a kind of report, and the user can select month/year. Sometimes, there will be different kinds of missing data in the source data for the listgrid.
    In those cases i want to display a popup with "warnings", but i still want to populate the listgrid with the data.

    client-side is basic, i have a listgrid, do an invalidatecache and i thought i'd have a callback to do a warn if the "errors" parameter in the dsresponse has any data in it.
    my testcode (the button is the one that triggers the fetch of report data):

    reportButton.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
    Date date = (Date) dateItem.getValue();
    final Criteria c = new Criteria();
    c.addCriteria("month", "" + (1 + date.getMonth()));
    c.addCriteria("year", "" + (1900 + date.getYear()));

    left.invalidateCache();
    left.fetchData(c, new DSCallback() {
    @Override
    public void execute(DSResponse response, Object o, DSRequest dsRequest) {
    try {
    Map m = response.getErrors();
    for (Object o1 : m.keySet()) {
    System.out.println(">>>error: "+o1+", "+m.get(o1));
    }
    } catch (Exception e) {
    SC.say("error: " + e.getMessage() + " ; " + e.toString());
    }
    ...

    So, when there are no errors in the dsresponse everythings work fine, and the listgrid is populated with data as expected.

    If i, however, serverside put an error in the errorobject like this:
    DSResponse resp = new DSResponse(reportTOList);
    resp.addError("warning", "test warning message");

    That error does get printed clientside in the callback systemout (as seen in the clientcode above), however no data is populated in the listgrid....

    Does the listgrid population abort because there's an error in the DSresponse errorobject? If i can't use the errors object in the dsresponse for "warnings", is there another way around it?

    Thankful for a pointer. Cheers.

    #2
    Actually, think i got something working here, using the DataClass.setAttribute(String property, String[] value), then
    response.getAttributeAsStringArray("warnings") clientside. Not sure if it's best practice, but seems to work.

    Cheers.

    Comment

    Working...
    X