我想在Omnifaces generic Converter中使用Primefaces autocomplete component 像这样:
<p:dataTable id="transactiondetailsid" value="# {stockTransactionsBean.stkTransHeader.stkTransDetailsList}" var="stkTransDet" rowIndexVar="rowIndex">
<p:column>
<f:facet name="header">
<h:outputText value="Item Code" />
</f:facet>
<p:autoComplete id="dd" dropdown="true" autocomplete="true"
value="#{stkTransDet.item}" var="i" itemLabel="#{i.itemnamee}"
itemValue="#{i}" converter="omnifaces.SelectItemsConverter"
completeMethod="#{stockTransactionsBean.completeItems}" forceSelection="true"
scrollHeight="250" minQueryLength="3" maxResults="30" queryDelay="1000" size="20" />
</p:column>
</p:dataTable>
但它无效,因为 omnifaces.SelectItemsConverter 依赖于 f:selectItems 标记,无法在 p:autoComplete
内使用任何建议或解决方法????
答案 0 :(得分:10)
使用专门为此目的设计的其他转换器ListConverter
。
<p:autoComplete value="#{bean.selectedItem}" completeMethod="#{bean.completeItems}">
<o:converter converterId="omnifaces.ListConverter" list="#{bean.availableItems}"/>
</p:autoComplete>
private String selectedItem; // +getter+setter
private List<String> availableItems; // +getter
public List<String> completeItems(String query) {
availableItems = someService.search(query);
return availableItems;
}