Announcement

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

    valueXPath help

    I seem to be missing something small here, but I cannot figure out why the valueXPath is not working:

    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/development/ISC_Core.js"></script>
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Foundation.js"></script>
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Containers.js"></script>
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Grids.js"></script>
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Forms.js"></script>
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_DataBinding.js"></script>
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Drawing.js"></script>
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_PluginBridges.js"></script> 
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Charts.js"></script>	
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Tools.js"></script>
    		<script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
    	 
    		<script type="text/javascript" >
    			var isomorphicDir="http://localhost:8080/isomorphic/";
    			
    			// set this to the correct JIRA ticket
    			var jiraTicket = "SNQA-431";
    			
    			// test data
    			var data = [
    				{ inspections: 32, project: { title: "ABC Project"} },
    				{ inspections: 14, project: { title: "Joe's Crab Shack"} },
    				{ inspections: 0, project: { title: "Pizza Hut"} },
    				{ inspections: 2, project: { title: "Home Depot"} }
    			];
    			
    			// datasource for the grid		
    			isc.DataSource.create({
    				ID: "ds",
    				fields: [
    					{name:"title", title:"Project Title", valueXPath: "project/title"},
    					{name:"inspections", type:"integer", title:"Inspection Counts"}
    
    				],
    				cacheData:data,
    				clientOnly: true
    			});
    			
    			// 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({
    				dataSource: ds,
    				dataFetchMode : "local",
    				autoFetchData: true,
    				clientOnly: true,
    				position: "relative",
    				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
    				]
    			});
    
    				
    		</script>
    
    	</body>
    
    </html>

    #2
    valueXPath applies to XML and JSON responses received as HTTP responses only. It does not apply to clientOnly cacheData.

    Comment


      #3
      Thanks, trying to write test case and was trying to simplify that step.

      Comment


        #4
        Did anything in 9.1 change with regards to data sources and valueXPath? I am still trying to get a standalone test case working, but it looks like our data is being flattened on the server side or by some fetchData process before its set on the grid. Therefore, my valueXPath is no longer valid.

        Example:

        My java bean is of the format:
        {
        inspections: 6,
        project: {
        title: "ABC",
        date: ...
        }
        }

        Before 9.1, this was not modified. But after 9.1, its flattened:
        {
        inspections: 6,
        title: "ABC",
        date: ...
        }
        Last edited by jwbst21; 31 Mar 2014, 11:51.

        Comment


          #5
          No, nothing changed. valueXPath in server-side .ds.xml files would always flatten data before it left the server. This is documented on dataSourceField.valueXPath.

          Comment


            #6
            OK. Let me work on a test case. After 9.1, I am not seeing the flattening of the data. Before 9.1 I did. I am checking our production environment (9.0 08/05) against my development environment (9.1 03/28). The production environment contains the project node in addition to all the properties of project flattened out in the record. So I am assuming that the valueXPath is used to flatten the data, then the field name is used to access the data?

            Again, our environment is quite complicated so I need to isolate it and slim the code down. However, upon first analysis it seems like the flattening is not occurring with 9.1.

            Comment


              #7
              So again, this property is actually documented:

              http://www.smartclient.com/docs/release/a/b/c/go.html#attr..DataSourceField.valueXPath

              The server behavior is explained in some depth, including how data are applied to beans or maps.

              And again, no, no intentional change, and all of our relevant automated tests are passing - we'll need a test case showing some specifics before there's any investigation we can do.

              Comment


                #8
                Submitted a new post for this issue: http://forums.smartclient.com/showthread.php?p=118211#post118211

                Comment

                Working...
                X