Tree HierarchicalContainer problem

Also added a test war containing sources for import convenience.

The error:

The code:

public class TestApplication extends Application {
	@Override
	public void init() {
		Window mainWindow = new Window("Test Application");
		Label label = new Label("Hello Vaadin user");
		mainWindow.addComponent(label);
		setMainWindow(mainWindow);
		getMainWindow().addComponent(new FilterTree());
	}

}
public class FilterTree extends Tree{
	
	public FilterTree(){	
		setContainerDataSource(FilterManager.getFilterHierarchicalContainer());
	}

}
public class FilterManager {
	
	private static final String FILTER_NAME = "name";
	private static final String[] filterImpactTypes = { "Passive filters", "Active filters" };
	private static final String[] filterTypes = { "Sums", "Parities", "Numbers" };
	
	public static HierarchicalContainer getFilterHierarchicalContainer(){
		HierarchicalContainer getFilterHierarchicalContainer = new HierarchicalContainer();
		getFilterHierarchicalContainer.addContainerProperty("FILTER_NAME", String.class, null);
		
		Item item = null;
		Integer itemId = 0;
		for(int i = 0; i < filterImpactTypes.length; i++ ) {			
			// Add new item
            item = getFilterHierarchicalContainer.addItem(itemId);
            // Add name property for item
          [color=#FF0808]
 [b]
 item.getItemProperty(FILTER_NAME).setValue(filterImpactTypes[ i ]
);
[/b]
[/color]
            // Allow children
            getFilterHierarchicalContainer.setChildrenAllowed(itemId, true);
            itemId++;
		}
		
		itemId = 100;
		for(int i = 0; i < filterTypes.length; i++ ){
			// Add new item
            item = getFilterHierarchicalContainer.addItem(itemId);
            // Add name property for item
            item.getItemProperty(FILTER_NAME).setValue(filterTypes[ i ]
);
            // Set parent
            getFilterHierarchicalContainer.setParent(itemId, 0);
            // Allow children
            getFilterHierarchicalContainer.setChildrenAllowed(itemId, false);
            itemId++;
		}
		
		
		return getFilterHierarchicalContainer;
	}
}

11316.war (3.39 MB)

This is even weirder, something changed in vaadin 6.34, i copied over ExampleUtil and used getHardware(), but instead of the names, i get the numbers of the ids:

EDIT: in the sampler on jetty it works, just not on tomcat 6.2
11317.png

Note these two lines

getFilterHierarchicalContainer.addContainerProperty("FILTER_NAME", String.class, null);
item.getItemProperty(FILTER_NAME).setValue(filterImpactTypes[ i ]
);

In the first one you are using the string “FILTER_NAME” and in the second you are using the same named field. The first one shouldn’t have quotes.

You are seeing numbers in the tree because you haven’t specified which property should be used as the caption and hence the item id is used as the caption. You need to call
setItemCaptionPropertyId()
for the tree.

Thank you. Guess i should get more sleep :grin:
Although i get the same error
:open_mouth:

The null exception moved to this line now:

item.getItemProperty(FILTER_NAME).setValue(filterTypes[ i ]
);

P.S. About ExampleUtil test. With the tree.setItemCaptionPropertyId(“asdf”); or tree.setItemCaptionPropertyId(1000);

after i:

item = hwContainer.addItem(1000);
        item.getItemProperty(hw_PROPERTY_NAME).setValue("test");

get me this (numbered is in FF, empty is in IE) :open_mouth:
11318.png
11319.png

I’ve used

Tree tree = new Tree("a;oigha;ogh");
		tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
		tree.setContainerDataSource(ExampleUtil.getHardwareContainer());
		tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
		getMainWindow().getContent().addComponent(tree);

for the test with ExampleUtil.getHardwareContainer()
and i got this internal error now:

java.lang.NullPointerException: Container item or property ids can not be null
	at com.vaadin.data.util.IndexedContainer$IndexedContainerProperty.<init>(IndexedContainer.java:1230)
	at com.vaadin.data.util.IndexedContainer$IndexedContainerProperty.<init>(IndexedContainer.java:1203)
	at com.vaadin.data.util.IndexedContainer.getContainerProperty(IndexedContainer.java:214)
	at com.vaadin.ui.AbstractSelect.getContainerProperty(AbstractSelect.java:731)
	at com.vaadin.ui.AbstractSelect.getItemCaption(AbstractSelect.java:1066)
	at com.vaadin.ui.Tree.paintContent(Tree.java:532)
	at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:746)
	at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:146)
	at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:746)
	at com.vaadin.ui.Panel.paintContent(Panel.java:250)
	at com.vaadin.ui.Window.paintContent(Window.java:564)
	at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:746)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.paintAfterVariableChanges(AbstractCommunicationManager.java:804)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:618)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:265)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:482)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:619)

This is so counterintuitive it makes me want to shoot myself for using it. It needs an interface… i have to start all the way down from the TreeSingleSelectExample, and work what i want from there. There’s danger jumping from all over the place :grin: