Using Tree Grid to display XML data

I have an XML data to be displayed in Tree grid. Based on the code sample and learning, I have designed few classes and tried to display it on Tree Grid but nothing comes out on the screen.

The following is the sample XML data

<configadmin>
   <service id="service1">
      <property name="minutes" type="STRING" value="120"/>
      <property name="seconds" type="STRING" value="60"/>
      <property name="hours" type="STRING" value="1"/>
   </service>
   <service id="service2">
         <property name="host" type="STRING" value="localhost"/>
         <property name="port" type="STRING" value="8080"/>
   </service>
</configadmin>
public class ConfigId {

   private String id;
   private List<ConfigProperty> configProperty = new ArrayList<>();

   public ConfigId(String id) {
      this.id = id;
   }

   /**
    * @return the id
    */
   public String getId() {
      return id;
   }

   /**
    * @param id the id to set
    */
   public void setId(String id) {
      this.id = id;
   }


   /**
    * @return the configProperty
    */
   public List<ConfigProperty> getConfigProperty() {
      return configProperty;
   }

   /**
    * @param configProperty the configProperty to set
    */
   public void setConfigProperty(List<ConfigProperty> configProperty) {
      this.configProperty = configProperty;
   }

   /**
    * @param configProperty the configProperty to add
    */
   public void addConfigProperty(ConfigProperty configProperty) {
      this.configProperty.add(configProperty);
   }

}

public class ConfigProperty{

   private String name;
   private String type;
   private String value;

   public ConfigProperty(String name, String type, String value) {
      this.name = name;
      this.type = type;
      this.value = value;
   }

   /**
    * @return the name
    */
   public String getName() {
      return name;
   }

   /**
    * @param name the name to set
    */
   public void setName(String name) {
      this.name = name;
   }

   /**
    * @return the type
    */
   public String getType() {
      return type;
   }

   /**
    * @param type the type to set
    */
   public void setType(String type) {
      this.type = type;
   }

   /**
    * @return the value
    */
   public String getValue() {
      return value;
   }

   /**
    * @param value the value to set
    */
   public void setValue(String value) {
      this.value = value;
   }

}

UI Code

      gridLayout.setSizeUndefined();
      gridLayout.setSpacing(true);
      Panel panel = new Panel("Configuration Settings");
      panel.setWidth("130px");
      TreeGrid serviceGrid = new TreeGrid();
      List<ConfigId> serviceList = xmlConfigDomParser.getServicesList();
      serviceGrid.setItems(serviceList);
      gridLayout.addComponent(panel, 0, 0);
      gridLayout.addComponent(button, 2, 0);
      gridLayout.addComponent(serviceGrid, 0, 2);

I am trying to solve the following scenario,

On clicking the Service ID, all the properties need to be displayed and only the values needs to be edited.

At first I am not able to display the data on the Tree Grid, please advise.

Service Id, Name, Type, Value
service1
        minutes, STRING, 120
        seconds, STRING, 60
        hours, STRING, 1
service2
        host, STRING, localhost
        port, STRING, 8080

We are using Vaadin 8.6.4

Hi,

Looks like you aren’t adding any columns to the TreeGrid?

-Olli

I updated the code and now I could atleast get some display even though results are not as expected.

TreeGrid serviceGrid = new TreeGrid(ConfigId.class);



I was getting the results like the below,
ConfigProperty                         Id
                                     calibration.instance.storage      
[config.util.ConfigProperty@2b93bdff,
config.util.ConfigProperty@3340c66d,
config.util.ConfigProperty@67d10831,
config.util.ConfigProperty@22ceb311]

I am following the example in the below link but could not succeed much,

https://stackoverflow.com/questions/45429492/how-to-set-multiple-levels-in-a-tree-grid-with-vaadin-8-1

Please advice