Announcement

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

    XPath usage - Form save data

    We have a complex java object with a structure define below.

    Class A{

    private String a;
    private B b;

    }

    Class B{
    private x;
    }


    and the data-source field defined on the client side as

    <fields>
    <field>
    <name>a</name>
    <title>a Title</title>
    </field>
    <field>
    <name>b</name>
    <title>b Title</title>
    <valueXPath>//B/b</valueXPath>
    </field>
    </fields>

    When we call save data on the form, the java object is populated using the following operation.

    A a = new A();
    dsRequest.getDataSource().setProperties(dsRequest.getValues(), a);

    The field a of class A is set but not field b. How do we set the field b of type B ?

    Thanks,
    Ashish Chugh

    #2
    Bad XPath - such an XPath will always select any instance of B, not the instance of B underneath the current record. Remove the "//" and please refer any XPath tutorial before attempting to use it.

    Comment


      #3
      We have used different options like

      1. <valueXPath>B/b</valueXPath>
      2. <valueXPath>//B/b</valueXPath>
      3. <valueXPath>B//b</valueXPath>
      4. <valueXPath>//B//b</valueXPath>

      but none of them worked for save operation.

      Comment


        #4
        Yes, those are all wrong. Again, you should probably read about XPath and JXPath before attempting to use the feature.

        Comment


          #5
          I translated the example incorrectly from actual source code. I meant it to be like below.

          1. <valueXPath>b/x</valueXPath>
          2. <valueXPath>//b/x</valueXPath>
          3. <valueXPath>b//x</valueXPath>
          4. <valueXPath>//b//x</valueXPath>

          Comment

          Working...
          X