Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6897961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:14:08+00:00 2026-05-27T07:14:08+00:00

im tryind to build an Vaadin tree from an XML file(MSDL), im stuck at

  • 0

im tryind to build an Vaadin tree from an XML file(MSDL), im stuck at adding child items to my tree. So far i can read from my XML file and display the the tags/info i want but i cant make an Hierarchical strukture out of it , e.g :

i have an XML file with some information about Planets and their moons and the galaxy they are in :

Milky Way
 -Sunsystem
  -Earth
   -"Moon"
  -Mars
    -Phobos
    -Deimos
  -Saturn
    -Titan
    -Tethys
Pinwheel Galaxy
 -somesystem
   -weirdPlanet1
     -moon1
     -moon2
   -weirdPlanet2
     -moon1
     -moon2

now i want to have the same strukture in my vaadin tree. i have tryed lots of things but the result was always the same : some null values where added to the tree of i could see only the galaxys but i couldnt expand them or i could see a tree with all the infos but there whee no strukture at all all planets / moons where just listed :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:14:09+00:00Added an answer on May 27, 2026 at 7:14 am

    I’m pretty sure this doesn’t have anything to do with the Tree itself. Instead of adding the data directly to the Tree, you can try this:

    1. Parse the XML data into a HierarchicalContainer
    2. Iterate through the HierarchicalContainer with the sample code below and verify that it’s identical to your XML file structure
    3. Bind the data container to the tree by calling Tree.setContainerDataSource(Container)

    Sample code to iterate through a HierarchicalContainer:

    void iterateContainer() {
        for(Object rootItemId : myContainer.rootItemIds()) {
            Item rootItem = myContainer.getItem(rootItemId);
            System.out.println(rootItem.getItemProperty(myLabelProperty).getValue());
    
            iterateChildren(rootItemId, 1);
        }
    }
    
    void iterateChildren(Object parentItemId, int indent) {
    
        for(Object childItemId : myContainer.getChildren(parentItemId)) {
            Item childItem = myContainer.getItem(childItemId);
    
            for(int i = 0; i < indent; i++) {
                System.out.print(" ");
            }
            System.out.println(childItem.getItemProperty(myLabelProperty).getValue());
    
            if(myContainer.hasChildren(childItemId)) {
                iterateChildren(childItemId, indent+1);
            }
        }
    
    }
    

    This is just some untested QnD code, but this should help you to iterate through the container.

    edit: Just noticed that my answer could have been (partially) a stupid solution, since Tree already utilizes HierarchicalContainer. You can initialize myContainer HierarchicalContainer myContainer = (HierarchicalContainer) myTree.getContainerDataSource(); and use the code above.

    edit2: And if the structure isn’t identical, see where it goes wrong and let the debugger do the rest .. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several Maven modules with Vaadin library dependency in the root pom.xml file.
I was trying Build For Archiving application (from Titanium Mobile) with xCode 4.4, but
I'm trying build a method which returns the shortest path from one node to
I have a std::vector< tr1::shared_ptr<mapObject> > that I'm trying build from data contained in
Trying to build dynamic output from json and using jq/template tmpl display rows/columns. Somehow
Im trying to build a query that will fetch all changed rows from a
I`m trying to build a application using the Fragment/Tabs and Pager from the android
Trying to build Wireshark from source as there is no Linux installer and I
Trying to build my android project with Buildr (Apache), but can't find any info
Im trying to build a little site using XML instead of a database. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.