Announcement

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

    Two issues with 3.1 grid filter date range dialog

    Smart GWT 3.1p v8.3p_2013-03-06/LGPL .

    The following test case exposes two issues with the date range dialog used to filter date list grid fields:

    Code:
    public class SmartGwt implements EntryPoint {
      public void onModuleLoad() {
        VLayout canvas = new VLayout();
        canvas.setMargin(20);
        ListGrid grid = new ListGrid();
        grid.setShowFilterEditor(Boolean.TRUE);
        grid.setAutoFetchData(Boolean.TRUE);
        grid.setWidth(500);
        grid.setHeight(200);
        grid.setDataSource(DateRangeDialogDS.getInstance());
        canvas.addMember(grid);
        canvas.draw();
      }
      
      private static class DateRangeDialogDS extends DataSource {
        private static DateRangeDialogDS instance = null;
        public static DateRangeDialogDS getInstance() {
          if (instance == null) {
            instance = new DateRangeDialogDS("dateRangeDialogDS");
          }
          return instance;
        }
        
        public DateRangeDialogDS(String id) {
          setID(id);
          setRecordXPath("/response/data/record");
          DataSourceIntegerField pkField = new DataSourceIntegerField("id");
          pkField.setHidden(Boolean.TRUE);
          pkField.setPrimaryKey(Boolean.TRUE);
          DataSourceDateField birthdateField = new DataSourceDateField("birthdate", "Birthdate");
          DataSourceTextField nameField = new DataSourceTextField("name", "Name");
          setFields(pkField, birthdateField, nameField);
          setDataURL("ds/daterangedialog.data.xml");
          setClientOnly(Boolean.TRUE);
        }
      }
    }
    The locale is forced to be de_CH in .gwt.xml!
    Code:
    <extend-property name="locale" values="de_CH"/>
    <set-property name="locale" value="de_CH" />
    Issue 1
    The date selected through the date picker in the dialog is not recognized by Smart GWT. Upon validation I get "Must be a date." (validator_notADate message key). No date (format) settings were manipulated with DateUtil.
    -> date-range-dialog.png

    Issue 2
    The error message '"To" field value cannot be earlier than "From" field value.' is not localized. DateRangeItem.setInvalidRangeErrorMessage(String) allows to modify this, the default is documented there, but there's no message key in com\smartgwt\client\i18n\SmartGwtMessages.properties. AFAIU there's no way I could call DateRangeItem.setInvalidRangeErrorMessage() in this case.
    -> date-range-dialog-II.png

    Sidenote
    Running the test case in dev mode one gets the following message in console:
    "[ERROR] [smartgwt] - 07:59:09.844:TMR0:WARN:StaticTextItem:isc_StaticTextItem_0[iconPlaceholder]:Attempting to apply event handlers to this item. Unable to get a pointer to this item's focus element"
    Attached Files

    #2
    See answers already provided in previous thread, but consider that the locale can set the date formatter without setting the input appropriately. Also make sure you have the latest build because several properties have been added to locale files.

    Finally, not that setDefaultProperties() means that locals files are not the only way to set i18n messages system-wide.

    Comment


      #3
      Originally posted by Isomorphic View Post
      Also make sure you have the latest build because several properties have been added to locale files.
      Indeed, the nightly from 2013-03-31 fixes issue I and the warning in the console (what I listed under "Sidenote").

      Originally posted by Isomorphic View Post
      Finally, not that setDefaultProperties() means that locals files are not the only way to set i18n messages system-wide.
      I'm aware of this. However, what is this widget that is displayed in the dialog? Isn't it a DateRangeItem? This one doesn't have a static setDefaultProperties() method...

      Comment


        #4
        RelativeDateItem.setDefaultProperties() is present in 4.0 (actually for all FormItem subclasses).

        Before 4.0, you'd need to use the JavaScript equivalent isc.RelativeDateItem.addProperties() - use of this method for setting system-wide defaults in covered in the Skinning guide.

        Comment


          #5
          Now I'm confused...

          The validation message we see is the default from DateRangeItem.setInvalidRangeErrorMessage(String). Your SmartClient docs suggest that DateRangeItem is the only widget with a invalidRangeErrorMessage member, don't see anything similar on RelativeDateItem?
          Last edited by fhisg; 21 Mar 2013, 08:22.

          Comment


            #6
            That's correct, that's the name of the property.

            What issue does this cause for you?

            Comment


              #7
              Ok, totally lost now... I either don't understand the APIs or your hints or you don't understand our problem (possibly a combination of all).

              Let me try again, maybe my previous explanations didn't make sense.

              Problem: the '"To" field value cannot be earlier than "From" field value.' validation message is in English when the rest of the application is in German.

              Dead end I: I see that if we did have control over this "date range filter dialog" (i.e. if it were a custom dialog with a DateRangeItem) we could invoke DateRangeItem.setInvalidRangeErrorMessage(String) and all would be good. However, we can't because Smart GWT does all the heavy lifting here, we simply enable the filter on the ListGrid.

              Dead end II: there's no static setDefaultProperties() method on DateRangeItem we could use to set the invalidRangeErrorMessage attribute system-wide.

              Dead end III: you said that we should use isc.RelativeDateItem.addProperties(). However, RelativeDateItem doesn't have an invalidRangeErrorMessage property at all. Confuses me.

              Comment


                #8
                Just a typo. You can use addProperties() in JavaScript to set invalidRangeErrorMessage on DateRangeItem (not RelativeDateItem as erroneously mentioned). DateRangeItem is the class that invalidRangeErrorMessage actually documented on (bear in mind, these docs are searchable).

                DateRangeItem, RelativeDateItem and all other FormItems support setDefaultProperties() in 4.0, for those uncomfortable with basic JavaScript calls.

                This message is also settable via the locale files now.

                Comment

                Working...
                X