3

I have a composite component with a dataScroller inside (tomahawk). In my xhtml I tried to use this component but I receive an error:

java.lang.IllegalArgumentException: could not find UIData referenced by attribute dataScroller@for = 'myTable'

The component:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:t="http://myfaces.apache.org/tomahawk">
<composite:interface>
    <composite:attribute name="for" targets="scroll"></composite:attribute>
    <composite:attribute name="paginatorMaxPages" />
</composite:interface>

<h:head>
</h:head>
<h:body>
    <composite:implementation>

        <div class="paginacao">
            <t:dataScroller id="scroll" for="#{cc.attrs.for}"
                styleClass="paginador" renderFacetsIfSinglePage="false"
                pageIndexVar="numeroPagina" pageCountVar="quantidadePaginas"
                rowsCountVar="quantidadeRegistros" paginator="true"
                paginatorMaxPages="#{cc.attrs.paginatorMaxPages}"
                paginatorTableClass="paginasPaginador"
                paginatorActiveColumnClass="negrito">

                <f:facet name="first">#{labels['paginacao.primeira']}</f:facet>
                <f:facet name="previous">#{labels['paginacao.anterior']}</f:facet>
                <f:facet name="next">#{labels['paginacao.proxima']}</f:facet>
                <f:facet name="last">#{labels['paginacao.ultima']}</f:facet>
            </t:dataScroller>
        </div>

    </composite:implementation>
</h:body>
</html>

My datatable:

<h:form>
 ...
    <t:dataTable id="myTable" var="item" value="#{mBean.lista}">
 ...
    </t:dataTable>
 ...
</h:form>       

<param:parametrosScroll id="dataScroller" for="myTable" paginatorMaxPages="5" />
lexpfb
  • 175
  • 3
  • 12

1 Answers1

3

To ensure reusability of multiple instances in the same view, composite components are inherently naming containers, like <h:form>, <h:dataTable>, etc. In your specific case, the relative client ID in for="myTable" will be searched in the context of <cc:implementation>, but there is no such component. Instead, it's outside the composite, in another naming container represented by <h:form>.

You've 2 options:

  1. Pass an absolute client ID after having given the <h:form> a fixed ID.

    for=":myForm:myTable"
    
  2. Use a tagfile instead of a composite.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555