I am trying to use Omnifaces generic Converter in Primefaces autocomplete component Like this :
<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>
But its not working because omnifaces.SelectItemsConverter depend on f:selectItems tag which can not be used inside p:autoComplete
Any suggestions or work arounds ????
Use the other converter specifically designed for this purpose, the 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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With