How pass a converter into a composite component with p:inputText?

357 Views Asked by At

I want to put a filter of a p:datatable into a composite component. The filter use the p:inputText tag and an p:ajax tag to define a typing delay. The problem is, that the converter inside the composite component do nothing. When I use javax.faces.Long, the filter is always String.

The working code, that I want to use in a facelet:

     <p:column headerText="colum title"
        filterBy="#{p.p.idx}" sortBy="#{p.p.idx}">
        <f:facet name="filter">
          <p:inputText id="indexFilterInput"
            converter="javax.faces.Long" class="ui-column-filter">
            <p:ajax event="keyup" delay="800"
              oncomplete="PF('portDT').filter()" />
          </p:inputText>
        </f:facet>
        <h:outputText value="#{portRow.portIdx}" />
      </p:column>

I put the f:facet into the composite component:

<ui:component xmlns="http://www.w3.org/1999/xhtml"
  xmlns:p="http://primefaces.org/ui"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:cc="http://xmlns.jcp.org/jsf/composite">
  <cc:interface>
    <cc:attribute name="widgetVar" />
    <cc:attribute name="delay" />
    <cc:attribute name="converter" />
    <cc:insertFacet name="filter" />
  </cc:interface>
  <cc:implementation>
    <f:facet name="filter">
      <p:inputText id="filterInput" converter="#{cc.attrs.converter}"
        class="ui-column-filter" type="search">
        <p:ajax event="keyup" delay="#{cc.attrs.delay}"
          oncomplete="PF('#{cc.attrs.widgetVar}').filter()" />
      </p:inputText>
    </f:facet>
  </cc:implementation>
</ui:component>

Here is the call of the component gf:filterField:

      <p:column style="width:4em"
        headerText="#{lbl['general.column.id']}" exportable="true"
        filterBy="#{p.p.id}" sortBy="#{p.p.id}">
        <gf:filterField id="index" widgetVar="portDT" delay="800" converter="javax.faces.Long"/>
        <h:outputText value="#{portRow.portId}" />
      </p:column>

When change the converter in the p:inputText inside the composite component, the converter is also ignored. I need to pass the converter as a parameter, because some columns are String columns and some are Long.

Is there any other tag in the cc:interface as cc:attribute?

0

There are 0 best solutions below