Can I use omnifaces generic converter in primefaces autocomplete component?
Asked Answered
Z

1

5

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 ????

Zimbabwe answered 13/7, 2013 at 16:1 Comment(0)
T
14

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;
}
Trinia answered 14/7, 2013 at 3:41 Comment(1)
it would be helpful to have this example at the showcase: showcase.omnifaces.org/converters/ListConverterSimplify

© 2022 - 2024 — McMap. All rights reserved.