Announcement

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

    #16
    Hello Isomorphic,

    After the long duration of time I have spent with you on this SplitDateTime widget, here is where I am at.

    In a DynamicForm, it behaves well and as expected.

    In a ListGrid as an editor, it is wrought with issues. Focus and tabbing is a disaster. You can't mouse click out of editing a new record. You can sometimes mouse click out of an existing record being edited. If you set ListGrid.canEdit(false), and the ListGrid is empty the editor field is displayed and can have data entered into it.

    Given the great deal of effort, along with the slew of issues I am prepared to completely abandon editing in a ListGrid.

    To make matters worse I am required to display and edit times in zulu time. However, the TimeItem appears to refuse to display times in anything but local time. It's quite interesting to watch the time of a record in the ListGrid increment its time by 4 hours just by opening it for editing and then closing it. And now it appears even all of my efforts that at least got me a FormItem that was functional, is now also completely out the window.

    Can you please provide feedback on how I can successfully meet the following requirements using your API:
    1. A DateTime item that forces the user to manually enter a time (Defaulting to a valid time is not optional).
    2. A DateTime item that displays and edits in zulu time, and completely ignores the browsers default locale.

    At this point I'm about ready to switch to HTML and JS to try and implement said functionality, but I am really hoping your API is capable of providing a simpler solution.

    A set of PickLists for Date and Time would be most ideal. The PickLists for Hours and Minutes could be defaulted to null values. Is it feasible that I could extend your pick list implementation of a DateTimeItem to add Hours and Minutes that defaulted to a null value, failed validation until set to a non null value, and getValue returned a Date in zulu time, and when a date was set on it, it would ignore browser locale and set picklist values according to the zulu time?

    Thanks in advance.

    Comment


      #17
      The root issue is that browser APIs for focus and tabbing are a bit of a disaster (completely inconsistent as to keyboard events, when the default behavior can be cancelled, when events fire, etc). It's very difficult to wrap all these browser issues in such a way that you can embed an arbitrary compound component into the middle of the ListGrid Editing system and have that "just work", because the editing system is already bristling with workarounds needed to support all the sophisticated key navigation built into the ListGrid while papering over browser bugs. Hence our suggestion to just use keyPress events to manually manage focus.

      And to clarify, you've experience a number of issues with embedding a compound editor into ListGrid editing, but nothing with editing in general.

      But on your current issues:

      About time values changing through an edit cycle: the "time" type, which the TimeItem edits, is the time in the absence of a day. It has no notion of "local time" or any other date information. Your problem suggests that you are feeding values obtained from a "datetime" field to the TimeItem.

      1. As you've indicated your SplitDateTimeItem is working fine except for tabbing issues. Have you considered just moving it to a modal pop-up, where the editorType for the ListGridField is just a StaticTextItem (to display the value) with a FormItemIcon to launch the pop-up?

      2. DateUtil.setDefaultDisplayTimezone() could be used to do this system-wide, is that what you want? It sounds like you may actually be asking for this because of confusion about time representations and the issue with TimeItem discussed above.

      Comment


        #18
        I have used DateUtil.setDefaultDisplayTimezone("+00:00").

        That being said the SplitDateTimeItem is being fed via a single dateTime field. So do I need to do tz adjustment for the local browser when parsing the dateTime to just a time?

        I will try the popup editor in the ListGrid.

        Comment


          #19
          A pure "time" value is stored in browser local time and the date portion is ignored (see Date and Time Format and Storage overview for full details). So you basically want to take the time fields (hour/minute/seconds) from your datetime value *as rendered in whatever timezone you want displayed*, call new Date() and call setHours() et al. Make sense?

          Comment


            #20
            It sounds like you are telling me to do what I am already doing?

            private void splitFields(Date date, CanvasItem canvasItem) {
            if(getCanvas() == null) {
            return;
            }
            DynamicForm form = (DynamicForm)canvasItem.getCanvas();
            if(date != null) {
            Date dateDate = new Date(date.getYear(), date.getMonth(), date.getDate());
            form.setValue("dateOnly", dateDate);
            Date timeDate = new Date();
            timeDate.setHours(date.getHours());
            timeDate.setMinutes(date.getMinutes());
            timeDate.setSeconds(date.getSeconds());
            form.setValue("timeOnly", timeDate);
            canvasItem.storeValue(date);
            }
            else {
            form.clearValue("dateOnly");
            form.clearValue("timeOnly");
            // canvasItem.clearValue();
            }
            }

            Comment


              #21
              date.getHours() et al are going to retrieve the value in the browser's current timezone. So if you've used DateUtil.setDisplayTimezone() to change the timezone for display, this will result in the wrong value shown in the TimeItem.

              Likewise, if you were to take the value from the TimeItem and call getHours(), that's browser local time too, so if you applied those values to Date instance you intended to store as a datetime value, you'd potentially shift the time there too.

              So this is where shifting comes from - round trip issues in showValue() and before storeValue().

              Comment


                #22
                Now I'm thoroughly confused, are you telling me not to change the display format?

                Comment


                  #23
                  Timezones are certainly confusing and we get non-bugs reported as bugs in this area all the time, so you are not alone :)

                  No, you can set or not set the display format as desired. But your logic for splitFields and combineFields needs to take this setting into account.

                  To put it very simply, if you setDisplayTimezone() to zulu time, zulu time will be displayed for datetime values in, for example, a ListGrid field that is not being edited, or in a StaticTextItem.

                  Now, getHours() will still return local time because setDisplayTimezone() is not going to affect this API. So time values returned by getHours() et al will not be in zulu time, they will be in the browser local time. So if you use these APIs to put together a Date instance to be shown in the TimeItem, it will not show the same time as your datetime value would show in a ListGrid field or StaticTextItem.

                  Follow?

                  Comment

                  Working...
                  X