Skip to content

Button caption not properly displayed when using container data source #8

@GoogleCodeExporter

Description

@GoogleCodeExporter
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;
            }

        };


Original issue reported on code.google.com by m...@matthewjosephtaylor.com on 7 Mar 2012 at 10:47

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions