本文介绍了我可以在primefaces自动完成组件中使用omnifaces通用转换器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 Omnifaces通用转换器 www.primefaces.org/showcase/ui/autoCompletePojo.jsf"rel =" noreferrer> Primefaces自动填充组件像这样:

I am trying to use Omnifaces generic Converter in Primefaces autocomplete componentLike 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> 

但是它不起作用,因为 omnifaces.SelectItemsConverter 取决于 f:selectItems 标记,该标记不能在 p:autoComplete

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

推荐答案

使用为此目的专门设计的另一个转换器 ListConverter .

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;
}

这篇关于我可以在primefaces自动完成组件中使用omnifaces通用转换器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 18:21