Announcement

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

    Help with DataSource setValueXPath

    Using SmartGWT 2.3 with RestDataSource

    Serverside data is delivered something like this.
    Code:
    <response>
      <data>
        <record>
          <id>123</id>
          <name>Name</name>
          <children>
            <child>
              <childId>555</childId>
              <childName>name</childName>
            </child>
            <child>
              <childId>666</childId>
              <childName>name</childName>
            </child>
          </children>
        </record>
      </data>
    </response>
    I have a DataSourceField declared for "childName"
    Code:
    DataSourceTextField field = new DataSourceTextField("childName" + childId);
    field.setValueXPath("children/child/childId[text()='"+ childId +"']/following-sibling::childName");
    Form Text Field:
    Code:
    TextAreaItem childNameField = new TextAreaItem("childName" + childId);
    The form on load correctly pulls in whatever value was stored on the server, however when submitting the form via "DSProtocol.POSTXML" it does not put the value back in the xpath location. Is there a way to make this happen?

    What is submitted to the server...
    Code:
    <response>
      <data>
        <record>
          <id>123</id>
          <name>Name</name>
          <childName555>Updated Name</childName555>
          <childName666>Updated Name</childName666>
          <children>
            <child>
              <elem>
                <childId>555</childId>
                <childName>name</childName>
              </elem>
              <elem>
                <childId>666</childId>
                <childName>name</childName>
              </elem>
            </child>
          </children>
        </record>
      </data>
    </response>
    Note: the restructuring of the XML doc with "elem" is also another problem (ideas on why that is happening?)
Working...
X