Primefaces自动完成作为数据表过滤器

时间:2016-06-22 10:25:54

标签: jsf primefaces

我无法使其发挥作用。 组件仅发送输入中实际内容的一部分。我应该使用什么事件来触发过滤,实际强制选择需要forceSelection旁边的选项:

This what is send from a request

InboundShipmentListForm:datalist:j_idt98_input:Select One...
InboundShipmentListForm:datalist:j_idt104_focus:
InboundShipmentListForm:datalist:j_idt104_input:Select One...
InboundShipmentListForm:datalist:j_idt110_input:p
InboundShipmentListForm:datalist:j_idt110_hinput:p

发生意外错误!消息:对于输入字符串:" p"

            <p:column filterBy="#{item.supplierPlant}"
                sortBy="#{item.supplierPlant}"
                headerText="#{bundle.ListInboundShipmentTitle_supplierPlant}"
                style="width:auto; text-align:center">

                <!-- autocomplete -->
                <f:facet name="header">
                    <f:facet name="filter">

                        <p:autoComplete forceSelection="true" itemValue="#{plant}" converterMessage="Select a value"
                            onchange="PF('datalist').filter()" dropdown="true"
                            onkeyup="PF('datalist').filter()"
                            completeMethod="#{inboundShipmentController.completeSuppliers}"
                            var="plant" itemLabel="#{plant.plantName}"
                            converter="plantConverter" a:placeholder="Start typing ..." />
                    </f:facet>
                </f:facet>
                <h:outputText value="#{item.supplierPlant.plantName}" />
            </p:column>

1 个答案:

答案 0 :(得分:3)

可靠的onkeyup事件发送的字符串不完整,而不是转换后的工厂。

尝试使用p:ajax代替onXX事件:

                <f:facet name="filter">
                    <p:autoComplete forceSelection="true" itemValue="#{plant}" converterMessage="Select a value"
                                    completeMethod="#{inboundShipmentController.completeSuppliers}"
                                    var="plant" itemLabel="#{plant.plantName}"
                                    converter="plantConverter" a:placeholder="Start typing ...">
                        <p:ajax event="itemSelect" onstart="PF('datalist').filter()" />
                    </p:autocomplete>
                </f:facet>