Announcement

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

    DayBodyClickHandler for Calendar is getting a Date with a different time after upgrade.

    Hi Isomorphic,

    After upgrading to SmartClient Version: v12.1p_2021-10-22/Pro Deployment (built 2021-10-22), the DayBodyClickHandler for the Calendar gets the correct date, but the time is now 12:00:00 instead of 00:00:00.

    This is causing the dates to no longer be equal when comparing them in the getDayBodyHTML method since it is passed a date with time 00:00:00.

    The following sample code can be used to reproduce the issue. After clicking on a date, it should display a checkmark but it doesn't because the date objects are not equal.

    Entry Point:
    Code:
    public class Sandbox19 implements EntryPoint {
    
        private Set<Date> dates = new TreeSet<>();
    
        public void onModuleLoad() {
    
            Calendar calendar = new Calendar() {
                @Override
                public String getDayBodyHTML(Date date, CalendarEvent[] events, Calendar calendar, int rowNum, int colNum) {
                    String returnStr = date.getDate() + "";
                    if (dates.contains(date)) {
                        returnStr += imgHTML("icons/16/approved.png", 16, 16, "image", null, null);
                    }
                    return returnStr;
                }
            };
    
            calendar.setWidth(500);
            calendar.setHeight(220);
            calendar.setShowDayView(false);
            calendar.setShowWeekView(false);
            calendar.setShowOtherDays(false);
            calendar.setShowDayHeaders(false);
            calendar.setShowDatePickerButton(false);
            calendar.setShowAddEventButton(false);
            calendar.setDisableWeekends(false);
            calendar.setShowDateChooser(false);
            calendar.setCanCreateEvents(false);
    
            calendar.addDayBodyClickHandler(event -> {
                Date date = event.getDate();
                if (dates.contains(date)) {
                    dates.remove(date);
                } else {
                    dates.add(date);
                }
                calendar.markForRedraw();
            });
    
            calendar.draw();
        }
    }
    Thanks.





    #2
    Thanks for the notification. We have assigned this for investigation. We'll follow up when we have more information for you

    Regards
    Isomorphic Software

    Comment


      #3
      These MonthView-related APIs should work with logical-dates (in which times are set to 12:00 but are ignored), since each cell in MonthView has one logical date.

      DayBodyClickHandler was already passed a logical-date, and we've fixed so that getDayBodyHTML() is passed one too.

      You can try out the change in builds dated October 30 and later.

      Comment


        #4
        This is resolved now. Thanks!

        Comment

        Working...
        X