Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

9.1 Regression: valueMap not working for grid

$
0
0
v9.1p_2014-03-28
This problem does not exist in v9.0p_2013_08_05

With the release of 9.1, the data being returned from the server is no longer being flattened as it was in 9.0. This is causing issues in our production environment as our grid is now missing important data.

This test case requires a server side data source and configuration, all of which are included in this post. I have significantly slimmed this test case down to illustrate the problem.

Reproduction steps:
- load test case in 9.1 (03/28)
- observe that the grid project title is blank
- open up a browser console, note that the data is not flattened for projectTitle:
Code:

//isc_RPCResponseStart-->[{affectedRows:0,data:[{project:{title:"ABC Inc."},inspections:16,observations:298},{project:{title:"Pizza Tent"},inspections:1,observations:5},{project:{title:"Wally World"},inspections:234,observations:2}],invalidateCache:false,isDSResponse:true,operationType:"fetch",queueStatus:0,status:0,total:3}]//isc_RPCResponseEnd
- load test case in 9.0 (08/05)
- observe that the grid project title field is populated
- open up a browser console, note that the data is flattened for projectTitle:
Code:

//isc_RPCResponseStart-->[{data:[{projectTitle:"ABC Inc.",project:{title:"ABC Inc."},inspections:16,observations:298},{projectTitle:"Pizza Tent",project:{title:"Pizza Tent"},inspections:1,observations:5},{projectTitle:"Wally World",project:{title:"Wally World"},inspections:234,observations:2}],invalidateCache:false,isDSResponse:true,operationType:"fetch",queueStatus:0,status:0,total:3}]//isc_RPCResponseEnd
While not in this test case, we build out the datasource config dynamically becuase the data is specific to the user. The only constant is the child object project. This test case illustrates a config where the data has inspections, observation and a project. However, another user may have unsafe count, last inspection date and project. The way that we implemented this was as a map, since the number of combinations for this data is too large to create separate java beans for each user.


Datasource Config
==============
Code:

<DataSource 
    ID="dsSNQA431" 
    serverConstructor="SNQA431Datasource"> 

        <fields>
                <field name="inspections" type="integer"  />
                <field name="observations" type="integer" />
                <field name="projectTitle" type="text" valueXPath="project/title"/>
        </fields>
       
</DataSource>

Datasource Class
==============
Code:

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.isomorphic.datasource.BasicDataSource;
import com.isomorphic.datasource.DSRequest;
import com.isomorphic.datasource.DSResponse;

public class SNQA431Datasource extends BasicDataSource
{

  @Override
  public DSResponse executeFetch( DSRequest req ) throws Exception
  {

    DSResponse response = new DSResponse();

    List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();

    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put( "project", new Project( "ABC Inc." ) );
    resultMap.put( "inspections", 16 );
    resultMap.put( "observations", 298 );
    resultList.add( resultMap );

    resultMap = new HashMap<String, Object>();
    resultMap.put( "project", new Project( "Pizza Tent" ) );
    resultMap.put( "inspections", 1 );
    resultMap.put( "observations", 5 );
    resultList.add( resultMap );

    resultMap = new HashMap<String, Object>();
    resultMap.put( "project", new Project( "Wally World" ) );
    resultMap.put( "inspections", 234 );
    resultMap.put( "observations", 2 );
    resultList.add( resultMap );


    response.setProperty( "total", resultList.size() );
    response.setData( resultList );

    return response;

  }
}

Project Class (used in response)
==============
Code:

public class Project {
 
    private String title;
   
    public Project() {};
   
    public Project(String title) {
      this.title = title;
    }
    public String getTitle()
    {
      return title;
    }

    public void setTitle( String title )
    {
      this.title = title;
    }
}

Test Case
==============
Code:

<!DOCTYPE html>

<html>
        <head>

                <title></title>
               
                <style>
                        .diagInfo {
                                font-size: 14px;
                                font-weight: bold;
                                padding: 5px;
                        }
                </style>
               
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Core.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Foundation.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Containers.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Grids.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Forms.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_DataBinding.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Drawing.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_PluginBridges.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Charts.js"></script>       
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
                <script src="http://localhost:8080/isomorphic/DataSourceLoader?dataSource=dsSNQA431"></script>
       
                <script type="text/javascript" >
                        var isomorphicDir="http://localhost:8080/isomorphic/";
                       
                        var ds = null;
                       
                        // set this to the correct JIRA ticket
                        var jiraTicket = "SNQA-431";

                        // once page loads set some diagnostic information
                        isc.Page.setEvent("load", function() {
                                document.title = jiraTicket + "  (SmartClient version " + isc.versionNumber + ")";
                                var html = [];
                                html.push("Jira: " + jiraTicket);
                                html.push("SmartClient: " + isc.versionNumber);
                                html.push("Browser: " + navigator.appCodeName + " " + navigator.appName + " " + navigator.appVersion);
                                diagLabel.setContents( html.join("<br>"));
                               
                               
                        });
                       
                </script>

        </head>
       
        <body>
                <script>
               
                        // this laebl should not be removed, all test cases should have this
                        var diagLabel = isc.Label.create({
                                                ID: "diagInfo",
                                                width: "100%",
                                                styleName: "diagInfo",
                                                autoFit: true
                                        });
                       
                        // basic grid               
                        var grid = isc.ListGrid.create({
                                autoFetchData: true,
                                position: "relative",
                                dataSource: "dsSNQA431",
                                width : "100%",
                                align : "center",
                                autoFitData : "vertical",
                                autoFitMaxHeight : 400,
                                alternateRecordStyles : true,
                                canAddFormulaFields : true,
                                canAddSummaryFields : true,
                                canGroupBy : true,
                                canReorderFields : true,
                                showGroupSummary : true,
                                groupByMaxRecords : 15,
                                useAdvancedFieldPicker: true,
                                advancedFieldPickerThreshold: 5,
                                autoDraw: false
                        });       
                                               
                        // the main page layout - place all other components afetr diagLabel
                        isc.VLayout.create({
                                width:"100%",
                                membersMargin: 20,
                                members: [
                                        // this must remain here to output diagnostic information
                                        diagLabel,
                                        // add any other components here
                                        grid
                                ]
                        });

                        grid.fetchData();
                </script>

        </body>

</html>


Viewing all articles
Browse latest Browse all 4756

Trending Articles