简体   繁体   中英

autocomplete not setting object primefaces

I have this autocomplete that works very well except for it not setting the value parameter in the backing bean

value="#{marketLoader.invSelectedItem}"

But it will only show the correct items from the search. But clicking an item does not set the object (not string). in the backing bean. The marketLoader.completeItemtext will return a List in this case. Is there a reason for the setInvSelectedItem() method not being called? Do I need a converter for this to work?

<p:autoComplete id="drop" dropdown="true" value="#{marketLoader.invSelectedItem}" 
        completeMethod="#{marketLoader.completeItemtext}" 
        var="item" itemLabel="#{item.typeName}"/>

The complete method

private invTypes invSelectedItem;
public List<invTypes> completeItemtext(String query) {
        if (query.length() < 3) {
            return null;
        }
        List<invTypes> tmpList = listDBItem.stream().filter(p -> p.getTypeName().contains(query))
                .collect(Collectors.toList()); 

        return tmpList;
    }

You are missing a converter in order to set the selected value correctly. See this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM