Announcement

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

    Missing API for DataSourceLocalization for dynamically loaded Datasources

    Hi Isomorphic,

    I'm using DataSourceLocalization using <fmt>-tags, which is working great.
    So far, the localisation of the DataSourceLoader and the GWT-Application is based on the request's locale (this is the default).

    Now I'm implementing a cookie based language selection which can override the default request's locale. I'm reading the cookie in my bootstrap html (or more exactly jsp) file and apply it like this:
    Code:
            <meta name="gwt:property" content="[B]locale=<%=userLanguage %>[/B]">
    ...
            <script src="lms/sc/DataSourceLoader<%=version %>&amp;[B]locale=<%=userLanguage %>[/B]&amp;dataSource=<%=outputDataSources()%>"></script>
    This is also working fine and documented in the DataSourceLocalization docs:
    This will cause Smart GWT Server to look for a ResourceBundle called "supplyItem", containing keys "itemTitle" and "itemLengthRangeValidator", and replace the <fmt:message> tags with the values from the resource bundle in the expected way. It obtains the user's Locale from the servlet request, but you can override this if you want to force an application-specific locale, regardless of the user's operating system settings. To do this, specify a "locale" parameter on HTTP requests to the DataSourceLoader and IDACall servlets (the latter is typically done via actionURL).
    But I also do have a DataSource with a DynamicDSGenerator that I load from within the application like this:
    Code:
    DataSource.load(dataSourceName, new Function() {
                        @Override
                        public void execute() {
                            batchUploader.setUploadDataSource(DataSource.get(dataSourceName));
                            mainWindowLayout.addMember(batchUploader, 1);
                            batchUploader.getUploadButton().enable();
                        }
                    });
    Here, DataSource.load() has no overload where I could specify a locale. Can you add it (5.1p)?


    In a related area (l10n of IDACall), I think a static method getActionURL() is missing. I'd like to do this:
    Code:
    RPCManager.setActionURL(RPCManager.getActionURL() + "&locale=" + myLocaleString);
    If this is reasonable and the correct way to do it, could you add this one as well to 5.1p?

    Thank you & Best regards
    Blama

    #2
    For a DynamicDSGenerator, use the DSRequest argument (when provided) to look up the locale either directly from the cookie, or from a request attribute if you store it that way after calculating it in an earlier phase.

    Yes, we can add getActionURL().

    Comment


      #3
      We've added RPCManager.getActionURL() to SGWT 5.1p and newer. It will be in the nightly builds dated 2016-04-13 and beyond.

      Comment


        #4
        Hi Isomorphic,

        thanks for adding.
        Code:
        RPCManager.setActionURL(RPCManager.getActionURL() + "?locale=" + Helper.getCookieOrBrowserLanguage());
        is working as expected.

        Best regards
        Blama

        Comment


          #5
          Hi Isomorphic,

          w.r.t. to #2 I think this is not possible.

          The logic is as follows:
          • Select profile in GUI SelectItem
          • ChangedHandler does BatchUploader destroy/recreate and calls
            DataSource.load(dataSourceName, new Function() {
            @Override
            public void execute() {
            batchUploader.setUploadDataSource(DataSource.get(dataSourceName));
          • This results in l10n'd column names for the BatchUploader grid.
          • On the server, this is called:
            @Override
            public DataSource getDataSource(String id, DSRequest dsRequest) {
          • It does XML loading of the ds.xml template and some uploadFieldName modification (this is what I have the "profile selection" for). dsRequest is null.
          • It returns:
            return DataSource.fromXML(doc);
          This doc still includes the <title><fmt:message key="mykey" /></title>.
          The processing of the fmt-tag is still done internally by the framework afterwards.

          So I still think one would either need a new overload for DataSource.load() or static URL getter/setter like for RPCRequest.

          This is also independent of my use case - loading DataSource definitions via DataSource.load() is IMHO currently not possible if you do not want the request's default locale as one can't provide the locale-parameter like in the main jsp/html file.

          Best regards
          Blama

          Comment


            #6
            You can simply add the locale parameter to the default DataSourceLoader URL - it's settable.

            Comment


              #7
              Sorry for bothering. Yes, it's working with
              Code:
              DataSource.setLoaderURL(DataSource.getLoaderURL() + "?locale=" + ...
              For some weird reason I assumed the API would be in RPCManager as well and did not find it there.

              Thank you & Best regards
              Blama

              Comment

              Working...
              X