2014-01-23 3 views
1

저는 프라임을 사용하여 JSF에서 복합 구성 요소를 구현했습니다.상위 컴포지트 구성 요소에서 'header'라는 패싯을 찾을 수 없습니다.

<ui:component ...> 
    <cc:interface> 
      <cc:facet name="header"/> ... 
    <cc:interface> 

<cc:implementation> 
    <p:dataTable> 
    <f:facet name="header"> 
     <c:choose> 
     <c:when test="#{empty cc.attrs.metadata.headerText}"> 
      <cc:insertFacet name="header" required="true"/> 
     </c:when> 
     <c:otherwise> 
     #{cc.attrs.headerText} 
     </c:otherwise> 
     </c:choose> 
    </f:facet> ... 
    </dataTable> 
</cc:implementation> 

일반 페이지에서 사용할 때 예상대로 데이터 테이블을 렌더링 할 때 정상적으로 작동합니다.

<ui:composition> 
    <nav:dataTable/> 
     <f:facet name="header"> 
      <h:outputText value="headerText" /> 
     </f:facet> 
</ui:composition> 

하지만 위의 복합 구성 요소를 사용하여 대화 상자의 내부를 사용할 때, 그것은 발생

component.xhtml '헤더'의 이름

면을 찾을 수 없습니다 28,54 @ 부모 id가 'j_idt129'인 복합 요소

링크 클릭시이 대화 상자를 호출하기 위해 ajax 호출을 만들고 있습니다. 대화 상자의 모양이 달라 콘솔에서이 오류가 발생합니다. 아무도 그것을 직면 했습니까? 어떤 도움이라도 정말 대단합니다.

+2

는해야하지 면을'

답변

2

cc:insertFacet은 전체 f:facet 태그를 삽입하므로 복합 구현 내의 다른 f:facet 태그에 포함시키지 마십시오. 로 사용

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

<h:body> 
    <composite:interface> 
     <composite:facet name="header" /> 
     <composite:attribute name="title" /> 
    </composite:interface> 

    <composite:implementation> 
     <p:dataTable> 
      <!-- If the facet is given at parent, insert it. 
      Otherwise, provide the title given by the attribute --> 
      <c:choose> 
       <c:when test="#{not empty cc.facets.header}"> 
        <composite:insertFacet name="header" /> 
       </c:when> 
       <c:otherwise> 
        <f:facet name="header"> 
         #{cc.attrs.title} 
        </f:facet> 
       </c:otherwise> 
      </c:choose> 

      <p:column headerText="column" /> 
     </p:dataTable> 
    </composite:implementation> 
</h:body> 
</html> 

: 사용자 정의 p:dataTable를 작성하는 것처럼 나는 그것이 JSTL 유틸리티를 사용하여 렌더링 조건부 인터페이스 선언으로 이미 존재하는 header facelet을 덮어 쓰기 쉽게 생각

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:comp="http://java.sun.com/jsf/composite/comp"> 

<f:view> 
    <h:head /> 
    <h:body> 
     <h:form> 
      <comp:myTable title="header"> 
       <f:facet name="header"> 
        <h:outputText value="text" /> 
       </f:facet> 
      </comp:myTable> 

      <comp:myTable title="Custom header" /> 

      <p:commandButton type="button" onclick="dialog.show()" 
       value="show in dialog" /> 

      <p:dialog widgetVar="dialog"> 
       <comp:myTable title="header"> 
        <f:facet name="header"> 
         <h:outputText value="text" /> 
        </f:facet> 
       </comp:myTable> 
      </p:dialog> 

     </h:form> 
    </h:body> 
</f:view> 
</html>