Announcement

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

    PickTreeItem displays parents->children->parents ad nauseum

    My pick list displays the parents (Tuition and Fines). When I select a parent (such as Tuition), I see the children (Grad Fees and LatePay). BUT, they have the triangles indicating that they have children (which they do not). When I mouse over one of the children, such as Grad Fees, the tree displays the parents (Tuition and Fines) again. This continues until the PickTreeItem is so confused that it says it has no contents.

    Obviously, I'm doing something stupid, but we can't see the error. Could you please help?!

    The form has:

    final PickTreeItem chargeSelect = new PickTreeItem();
    chargeSelect.setValueField("id");
    chargeSelect.setDisplayField("description");
    chargeSelect.setTitle("Charge");
    chargeSelect.setDataSource(ManualChargesDataSource.getInstance());
    chargeSelect.setCanSelectParentItems(false);
    chargeSelect.setRequired(true);


    The ManualChargesDataSource code is:

    public class ManualChargesDataSource extends RestDataSource {
    private static ManualChargesDataSource instance = null;

    public static ManualChargesDataSource getInstance() {
    if (instance == null) {
    instance = new ManualChargesDataSource("manualChargesDS");
    }
    return instance;
    }

    public ManualChargesDataSource(String id) {
    setID(id);
    setRecordXPath("/response/data/chargeClassificationTree");

    DataSourceIntegerField pkField = new DataSourceIntegerField("id");
    pkField.setHidden(true);
    pkField.setPrimaryKey(true);

    DataSourceIntegerField parentIdField = new DataSourceIntegerField("parentId");
    parentIdField.setHidden(true);
    parentIdField.setForeignKey("manualChargesDS.id");
    parentIdField.setRootValue("root");

    DataSourceTextField codeField = new DataSourceTextField("code", "Code");
    DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");

    setFields(pkField, parentIdField, codeField, descriptionField);

    setDataURL(DataSourceBase.URL_PREFIX + "Common/ManualCharges");
    setClientOnly(false);
    }
    }


    And the exact XML I am sending from the server is:

    <response>
    <status>0</status>
    <data class="list">
    <chargeClassificationTree>
    <id>G10</id>
    <parentId>C1</parentId>
    <code>GradFees</code>
    <description>Student Graduation Fees</description>
    </chargeClassificationTree>
    <chargeClassificationTree>
    <id>C1</id>
    <parentId></parentId>
    <code>TUITION</code>
    <description>Student Tuition</description>
    </chargeClassificationTree>
    <chargeClassificationTree>
    <id>G9</id>
    <parentId>C1</parentId>
    <code>LatePay</code>
    <description>Student Late Payment Fine</description>
    </chargeClassificationTree>
    <chargeClassificationTree>
    <id>G8</id>
    <parentId>C4</parentId>
    <code>LibFine</code>
    <description>Student Library Fine</description>
    </chargeClassificationTree>
    <chargeClassificationTree>
    <id>C4</id>
    <parentId></parentId>
    <code>FINES</code>
    <description>Fines</description>
    </chargeClassificationTree>
    <chargeClassificationTree>
    <id>G7</id>
    <parentId>C4</parentId>
    <code>ParkFine</code>
    <description>Student Parking Fine</description>
    </chargeClassificationTree>
    </data>
    </response>

    I am using GWT version 2.0.3 and SmartGwt version 2.2.

    Thanks!!

    #2
    Use TreeNode.isFolder to indicate that a child does not have further children. isFolder can be set right in your REST response, as just isFolder="false".

    Comment


      #3
      I'm sorry, but I don't understand. Does that mean the XML from the servlet should have:

      <response>
      <status>0</status>
      <data class="list">
      <chargeClassificationTree>
      <id>G10</id>
      <parentId>C1</parentId>
      <code>GradFees</code>
      <description>Student Graduation Fees</description>
      <isFolder>false</isFolder>
      </chargeClassificationTree>
      ...

      Comment


        #4
        Well, I tried that and it didn't work, so I guess I don't understand what change you need me to make. Could you please try again?

        Thanks!

        Comment


          #5
          Once I returned the RIGHT values for isFolder, then everything worked.

          Thanks!!

          Comment

          Working...
          X