Announcement

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

    skin dir problem and datasource problem after upgraded form smartgwtpro 4.1b2013122

    we have a very large project by using smartgwtpro 4.1 build 2013-12-22, it works fine before we decided to upgrade to smartgwtpro 4.1 build 2014-07-18,

    first problem is :

    we have a custom skin dir, and we did set the path in load_skin.js by

    Code:
    isc.Page.setSkinDir("[ISOMORPHIC]/skins/MySkin/");
    isc.Page.loadStyleSheet("[SKIN]/skin_styles.css", theWindow);
    suppose our module name is : "main" and our web app can be accessed by :

    http://localhost:8080/app

    this way works fine before we upgrade it, the js will load skin_styles.css from

    http://localhost:8080/app/main/sc/sk...kin_styles.css

    after version upgraded, the url changed to

    http://localhost:8080/isomorphic/ski...kin_styles.css

    the path changed , we notice that the directory name "[ISOMORPHIC]" changed to "http://localhost:8080/isomorphic" somehow,

    so some additional settings might required ?


    the second problem is :

    we use RestDataSource in our project, and we also override its method :

    Code:
    protected Object transformRequest(DSRequest dsRequest) {
         switch (dsRequest.getOperationType()) {
             
              case UPDATE :
              case ADD: {
                    .......
                    return JSON.encode(dsRequest.getData());
              }
                    break;
              default : {
                    ......
                   return super.transformRequest(dsRequest);
              }
         }
    }
    according to api description, we override this method because we need a json object as the request body for our custom rest service in server side and return a json object too. it works fined before upgrade as well as first problem.

    however, after upgrade,
    browser complains "a error that some object has no selectString method".


    we noticed some changes in method " transformResponse : function (dsResponse, dsRequest, data) " in ISC_DataBinding.js

    in our working build 2013-12-22 for line 57973
    Code:
       if (this.dataFormat == "json") {
            //do json response
            .....
       }else{
           //do xml response
           dsResponse.status = this.getValidStatus(data.selectString("//status"));
           ......
       }

    in build 2014-07-18, it changed to

    Code:
        if (dsRequest.dataFormat == "json") {
            //do json response
            .....
       }else{
           //do xml response
           dsResponse.status = this.getValidStatus(data.selectString("//status"));
           ......
       }
    the code changed judgement statement from "this.dataFormat" to "dsRequest.dataFormat", however the only place we found to set the value of dsRequest.dataFormat is in

    line : 64612 in transformRequest function.
    Code:
        dsRequest.dataFormat = (this.clientOnly ? "json" : this.dataFormat);
    however, if we override method (java)transformRequest in the cases of UPDATE and ADD, the js version method (javascript)transformRequest will never called. so dsRequest.dataFormat aalways null, it will be recognized as a xml response

    Unless we still can super.transformRequest(dsRequest) before we return the js object

    Code:
       super.transformRequest(dsRequest);
       return JSON.encode(dsRequest.getData());
    another solution is we set the value of dataFormat manually

    Code:
       dsRequest.setAttribute("dataFormat", "json");
    it seems that both solution work for test, but we are sure these are correct way to handle it.


    any suggestion for it ? Thanks a lot!
    Last edited by woodfox; 18 Jul 2014, 21:20.

    #2
    First problem: you were probably setting isomorphicDir before, and somehow during the upgrade you lost this setting from your .html file or wherever you were previously setting it

    Second problem: if you are using a completely custom format, you should not be using RestDataSource. Just use DataSource. It doesn't make sense to be using RestDataSource, yet override transformRequest/transformResponse and never call Super. At that point you are using none of the behavior of RestDataSource.

    Comment


      #3
      Thanks for reply!

      1, setting the value of isomorphicDir and then the code works

      however I am still curious why it worked before(we really never set it before in smartgwt and we only use it ever in smartclient)

      finally I found there are some code in first line of ISC_Core.js before.

      Code:
         if(typeof isomorphicDir == 'undefined'){isomorphicDir = 'main/sc/';}
      well, I know it should not be there since not every one uses "main" as the module name. so that code removed in latest version.

      In a word, I manually set the value of isomorphicDir in html file.


      2, replace RestDataSource with DataSource made the code works too.

      Comment


        #4
        Originally posted by woodfox View Post
        Thanks for reply!
        In a word, I manually set the value of isomorphicDir in html file.
        That's exactly what happens in all the samples, see BuiltInDS.html:
        Code:
            <!-- IMPORTANT : You must set the variable isomorphicDir to [MODULE_NAME]/sc/ so that the SmartGWT resource are 
        	  correctly resolved -->	
        	<script> var isomorphicDir = "builtinds/sc/"; </script>
        Best regards,
        Blama

        Comment

        Working...
        X