Announcement

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

    Posting Hierarchical XML

    Hi Isomorphic,

    I wish to submit a nested custom XML back to the server using DataSource.

    Fetched XML Format:
    Code:
    <response>
       <data>
          <record>
             <field1>Field1 Value</field1>
             <group>
                <field2>Field2 Value</field2>
             </group>
          </record>
        </data>
    </response>
    This is not the plain name-value mapping instead has an one more level of nesting. I was able to fetch the data correctly into the form used valueXpath with the datasource field. While saving I expected datasource to update the XML using XPATH attribute but it doesn't.
    XML format while saving data was :
    Code:
    <request>
        <data>
        	<field2>Updated Field2 value</field2>
        	<field1>Updated Field1 value</field1>
        	<group>
        		<field2>Field2 Value</field2>
        	</group>
        </data>
    </request>
    Following is the code which I am using
    Code:
    		isc.DataSource.create({
    			ID:"contacts",
    			dataFormat:"xml",
    			recordXPath:"/response/data/record",
    			dataURL:"http://localhost:8011/test/data",
    			fields:[
    				{name:"field1"},
    				{name:"field2", valueXPath:"group/field2"},
    			],
    			transformRequest : function (dsRequest) 
    			{
    				alert(this.xmlSerialize(dsRequest));
    				var params = {"data":dsRequest.data};
    				return this.xmlSerialize(params, null, null, "request");
    			},
    			operationBindings:[
    				{
    					operationType:"update", dataProtocol: "postMessage",
    					dataURL:"http://localhost:8011/test/data"
    				}
    			]
    		});
    
    		isc.DynamicForm.create({
    			ID: "exampleForm",
    			width: 250,
    			dataSource: contacts,
    			 autoFetchData: true
    
    		});
    
    		isc.IButton.create({
    			left:0, top:40, width:50,
    			title:"Save",
    			click: function () {
    				exampleForm.saveData();
    			}
    		});
    Please tell me how can I update the request XML correctly. FYI, I am not using smartclient server.

    REF: DataSource Field Reference Doc for valueXpath says:
    When you are saving data, the inbound DSRequest values, available as a Java Map, will use just dataSource field names as Map keys, not the valueXPath used to derive them. However, to achieve bidirectional valueXPath binding, you can use the server-side method dataSource.setProperties() to use the valueXPath when setting properties on your server object model.

    I want to send the XML in a proper format to server so need to convert the XML at client side only. I tried using XMLTools api too but that too didn't helped me. I am blocked on this issue please lemme know the workaround or solution for this ASAP.
    Last edited by ajjain; 25 Jun 2009, 07:44. Reason: instant email notification.
Working...
X