Issue 8: Button caption not properly displayed when using container data source
Status:  New
Owner: ----
Reported by m...@matthewjosephtaylor.com, Mar 7, 2012
What steps will reproduce the problem?
1. Create a new TokenField and setTokenCaption on a series of itemId, caption pairs
2. call setPropertyDataSource(...) with a set of items that contain the same itemIds as step 1.
2. call setContainerDataSource(...) with a set of items that contain the same itemIds as step 1.

What is the expected output? What do you see instead?
Expect to see the caption on the buttons instead of the itemId.

What version of the product are you using? On what operating system?
v1.0 of tokenfield
v6.7.5 of vaadin

Please provide any additional information below.

The problem appears to be the fact that TokenField.getTokenCaption(Object tokenId) attempts to first see if the item exists in the CombBox that TokenField proxies.  During setPropertyDataSource those items won't exist yet until after the call completes.

Code to work-around the issue (and possibly fix long-term (not sure why the original code contains the extra cb.containsId check)) is:

		final TokenField tokenField = new TokenField() {
			
		    public String getTokenCaption(Object tokenId) {
		    	String caption = cb.getItemCaption(tokenId);
		    	if(caption == null) {
		    		caption = "" + tokenId;
		    	}
		    	return caption;
		    }

		};