Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use omnifaces generic converter in primefaces autocomplete component?

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

like image 778
Samy Omar Avatar asked Jul 13 '13 16:07

Samy Omar


1 Answers

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;
}
like image 171
BalusC Avatar answered Sep 22 '22 14:09

BalusC