2017-04-11 6 views
1

primefaces dataTable에서 복합 구성 요소를 만들 때 다음 오류가 발생합니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까 !? 복합 구성 요소를 사용하여 tabela-padrao.xhtmlp : dataTable에서 복합 구성 요소를 만들 때 '구성 요소가 이벤트를 지원하지 않습니다'오류가 발생했습니다.

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:cc="http://xmlns.jcp.org/jsf/composite" 
    xmlns:c="http://java.sun.com/jsp/jstl/core" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:f="http://xmlns.jcp.org/jsf/core" 
    xmlns:h="http://xmlns.jcp.org/jsf/html"> 

<!-- INTERFACE --> 
<cc:interface> 
    <cc:attribute name="uniqueId" required="true" /> 
    <cc:attribute name="value" required="true" /> 
    <cc:attribute name="var" required="true" /> 
    <cc:attribute name="selection" required="true" /> 
    <cc:attribute name="exportedFileName" required="true" /> 
    <cc:attribute name="renderedTable" default="true"/> 
    <cc:attribute name="primaryKey" required="true"/> 

</cc:interface> 

<!-- IMPLEMENTATION --> 
<cc:implementation> 
    <p:dataTable value="#{cc.attrs.value}" 
       id="#{cc.attrs.uniqueId}" 
       scrollable="true" 
       scrollWidth="100%" 
       var="#{cc.attrs.var}" 
       rendered="#{cc.attrs.renderedTable}" 
       selection="#{cc.attrs.selection}" 
       rowKey="#{cc.attrs.primaryKey}"            
       selectionMode="single" 
       paginator="true" 
       rowsPerPageTemplate="15,30,45" 
       paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}" 
       emptyMessage="#{bundle.tabela_nenhum_registro_encontrado}"> 
     <cc:insertChildren/> 
     <f:facet name="{Exporters}"> 
      <h:commandLink style="padding: 5px 5px 5px 5px ;" title="Converter para Excel" >            
       <h:outputText styleClass="fa fa-file-excel-o Fs20"/> 
       <p:dataExporter type="xls" target="#{cc.attrs.uniqueId}" fileName="#{cc.attrs.exportedFileName}" /> 
      </h:commandLink> 
      <h:commandLink style="padding: 5px 5px 5px 5px ;" title="Converter para PDF" > 
       <h:outputText styleClass="fa fa-file-pdf-o Fs20"/> 
       <p:dataExporter type="pdf" target="#{cc.attrs.uniqueId}" fileName="#{cc.attrs.exportedFileName}"/> 
      </h:commandLink> 
     </f:facet> 
    </p:dataTable> 
</cc:implementation> 

Exception 

    javax.faces.view.facelets.TagException: /view/restrito/basico/municipio.xhtml @77,165 <p:ajax> Composite component does not support event rowSelect 

/우산 오 componente

당신이 작성하고 복합에서 사용자 정의 이벤트를 등록해야
<h:form id="tabela-municipio"> 
        <ezcomp:tabela-padrao value="#{municipioMB.listaMunicipios}" 
              uniqueId="id-tabela-municipio" 
              var="mun" 
              primaryKey="#{mun.id}" 
              selection="#{municipioMB.municipio}" 
              exportedFileName="municipios"> 
         <p:ajax event="rowSelect" listener="#{municipioMB.onRowSelect}" update="@(form[id*='frm-municipio']),@(form[id*='tabela-municipio'])" /> 
         <p:ajax event="rowUnselect" listener="#{municipioMB.onRowUnselect}" update="@(form[id*='frm-municipio']),@(form[id*='tabela-municipio'])" /> 
         <p:column headerText="Pais" width="300" filterBy="#{mun.estado.pais.nome}" filterMatchMode="contains"> 
          <h:outputText value="#{mun.estado.pais.nome}"/> 
         </p:column> 
         <p:column headerText="Estado" width="300" filterBy="#{mun.estado.sigla} - #{mun.estado.nome}" filterMatchMode="contains"> 
          <h:outputText value="#{mun.estado.sigla} - #{mun.estado.nome}"/> 
         </p:column> 
         <p:column headerText="Município" filterBy="#{mun.nome}" filterMatchMode="contains"> 
          <h:outputText value="#{mun.nome}"/> 
         </p:column> 
        </ezcomp:tabela-padrao> 
       </h:form> 

답변

4

해당 작업을 데이터 테이블에 전달합니다. rowSelect 및 rowUnselect 이벤트는 복합 구성 요소가 아니라 데이터 테이블에 등록됩니다. clientBehavior를 사용하여 복합 컴포넌트에 대한 이벤트를 등록하십시오.

<cc:interface> 
    ... 
    <cc:clientBehavior name="customRowSelectEvent" targets="idOfDataTable" event="rowSelect" /> 
    <cc:clientBehavior name="customRowUnselectEvent" targets="idOfDataTable" event="rowUnselect" /> 
</cc:interface> 
  1. 이름은 사용자 정의 이벤트의 이름입니다.
  2. targets는 실제로 작업을 등록하려는 구성 요소의 ID입니다. 귀하의 경우에는 ID의 datatable.
  3. 이벤트는 데이터 테이블에 등록하려는 실제 이벤트입니다.

복합 구성 요소의 이벤트를 등록하십시오.

<ezcomp:tabela-padrao ....> 
    <f:ajax event="customRowSelectEvent" listener="#{municipioMB.onRowSelect}" update="@(form[id*='frm-municipio']),@(form[id*='tabela-municipio'])" /> 
    <f:ajax event="customRowUnselectEvent" listener="#{municipioMB.onRowUnselect}" update="@(form[id*='frm-municipio']),@(form[id*='tabela-municipio'])" /> 
     .....     
</ezcomp:tabela-padrao> 
+0

이 예외가 발생했습니다./Ocorreu esta exceção! Advertisction : StandardWrapperValve [Faces Servlet] : 서블릿 Faces 서블릿에 대한 Servlet.service()가 예외를 던졌습니다. java.lang.IllegalArgumentException –

+0

이것은 초기 문제에 대한 답변입니다. 새로운 문제는 새로운 질문을 필요로하지만 당연히 먼저 조사해야합니다. 제발 대답을 – Kukeltje

+0

acce하십시오. 감사 ! –