Lazy Loading/Loading on demand of components

I use the tree as a navigation menu, usually the tree is on the left site and on the right site the selected components are displayed.

This is and example of the current code:

                final Tree tree = new Tree();
		tree.addListener(new Property.ValueChangeListener() {

			private static final long serialVersionUID = -3064681487232625595L;

			public void valueChange(ValueChangeEvent event) {
				if (event.getProperty().getValue() != null) {
					setRightContent((Component) event.getProperty().getValue());
                CustomTypeScreen customTypeScreen = new CustomTypeScreen(clubadminController);
		tree.setItemIcon(customTypeScreen, new ThemeResource("images/clubadmin/customType24.png"));
		tree.setItemCaption(customTypeScreen, " Ereignistypen");
		TotalReservationStatOverview statOverview = new TotalReservationStatOverview(clubadminController); 
		tree.setItemIcon(statOverview, new ThemeResource("images/chart24.png"));
		tree.setItemCaption(statOverview, " Reservierungsstatistik");

At the moment as you see all components will be created during loading the application in the browser. But the usual user will only use five or six components of the whole application therefore I would like to have a mechanism that the component will only be created if the user clicks in the tree on it. Until now I did not find a way to do this.


Not sure if I understand you correctly,

but I would implement the tree as it’s own structure, without linking it to the real screens.
Then you use a factory to generete the required screens as needed (when selected in the tree)

Thank you for your answer, this was also my first guess but howver I din´t get it to work.

I woul like to add to EACH item of the tree something like a click listener, as I do it with buttons, but however this does not seem to exist.

Thank you,

Hello Florian,

depends what you did, but basically the click-events get catched by the tree itself to select/deselect values and open/close children.
What type of components do you have in the tree ? (Buttons, Links, Labels ?)