getItemProperty and null


        IndexedContainer ct = new IndexedContainer();
        ct.addContainerProperty("p1", String.class, "");
        Item item = ct.addItem("item1");
        Property property = item.getItemProperty("p2");
        if (property != null) System.out.println("ok");

Why is this code returns “ok” ? Property with the id “p2” does not exist.

Hi Andrey,

After reading javadoc, I think your code should never print ok.

But when I looked at the source for the getItemProperty() in the implementation of Item in the class IndexedContainerItem, I found that the method always return a new object

  /*
         * (non-Javadoc)
         * 
         * @see com.vaadin.data.Item#getItemProperty(java.lang.Object)
         */
        public Property<?> getItemProperty(Object id) {
            return new IndexedContainerProperty(itemId, id);
        }

So what’s is wrong : this method above or javadoc ?..
Hope Vaadin guys see that post and give us an explanation.

Regards.

Indeed, IndexedContainerItem.getItemProperty(…) behavior is not consistent with the inherited javadoc.

There is already a ticket for this (
#7103
).