如何强制组合框渲染自动完成选项?

Dra*_*tis 6 java zk

这是我的zul代码:

<combobox id="digitalPublisherCombobox" value="@load(ivm.inventory.digitalPublisherName)"
        onOK="@command('setDigitalPublisher', digitalPublisherBox = self)" 
        onSelect="@command('setDigitalPublisher', digitalPublisherBox = self)"
        onChanging="@command('setupQuicksearchByEvent', searchlayout = event, prefix = 'PUB', tags = 'PublisherName, PublisherNameTranslit')"
        mold="rounded" hflex="1" buttonVisible="false" autodrop="true">
    <comboitem self="@{each=entry}" value="@{entry.key}" label="@{entry.value}"/>
</combobox>
Run Code Online (Sandbox Code Playgroud)

这是QuickSearch实现:

@Command
public void setupQuicksearchByEvent(@BindingParam("searchlayout")Event event, @BindingParam("prefix") String prefix, @BindingParam("tags") String tags) throws WrongValueException, SearchException, IOException
{
    if(event instanceof InputEvent)
    {
        InputEvent inputEvent = (InputEvent) event;
        String inputText = inputEvent.getValue();

        List<String> searchFields = Arrays.asList(tags.split(","));
        ListModel model = new ListModelMap(ZKLogic.findDocsStartingWith(prefix, searchFields, "proxy", inputText), true);
        ListModel subModel = ListModels.toListSubModel(model, Autocompleter.MAP_VALUE_CONTAINS_COMPARATOR, 10);    
        Combobox searchBox = (Combobox) event.getTarget();
        searchBox.setModel(subModel); 

        searchBox.setItemRenderer(new ComboitemRenderer()
        {
            @Override
            public void render( Comboitem item, Object data, int pos ) throws Exception
            {
                String publisherString = data.toString();
                UID key = getUidFromPublisherString(publisherString);

                int startIndex = publisherString.indexOf('=') + 1;
                String publisher = publisherString.substring(startIndex);

                item.setLabel(publisher);
                item.setValue(key);
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

ZKLogic.findDocsStartingWith 返回带有UID-key和String-value的映射.

使用上面的代码,当我切换到另一个窗口时,我实现了下拉列表.我需要输入内容,然后选择另一个浏览器或记事本窗口 - 并且会立即显示comboitems.

所以,我的问题仍然需要回答,是否有任何技术可以在代码中重现这个窗口切换?或者我可能应该使用自动完成功能,因为我有一些使用预加载列表的交流,但是每当用户在字段中输入内容时,这个东西应该只返回来自db的10条记录,而不是所有70000条目.

编辑20/09/2013:问题仍然存在.重命名一下问题,因为我需要的是在代码中强制调用render选项.有办法吗?代码没有太大变化,但是渲染方法中的print选项表示,该方法可能会错过两个或更多onChange事件并突然为一个变体呈现文本.

也许你知道数据库参与的zk框架中的另一个自动完成选项?我已经准备好改变实现,如果有一个指导工作实现它.

Dra*_*tis 0

解决方案很简单。真的。没有什么比暴力更好的了,但我想我试图避免它并在绝望中使用它。

 @Command
public void setupQuicksearchByEvent(@BindingParam("searchlayout")Event event, @BindingParam("prefix") String prefix, @BindingParam("tags") String tags) throws WrongValueException, SearchException, IOException
{
    if(event instanceof InputEvent)
    {
        InputEvent inputEvent = (InputEvent) event;
        String inputText = inputEvent.getValue();

        List<String> searchFields = Arrays.asList(tags.split(","));
        Map<UID, String> publishers = ZKLogic.findDocsStartingWith(prefix, searchFields, "proxy", inputText);

        Combobox searchBox = (Combobox) event.getTarget();
        searchBox.getChildren().clear();

        for (Map.Entry<UID, String > entry : publishers.entrySet())
        {
            Comboitem item = new Comboitem();
            item.setLabel(entry.getValue());
            item.setValue(entry.getKey());
            searchBox.appendChild(item);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)