1
votes

I have a custom dialog component using Primefaces:

myDialog.xhtml

<!-- INTERFACE -->
<cc:interface>

    <cc:attribute name="header" />
    <cc:attribute name="id" />

</cc:interface>

<!-- IMPLEMENTATION -->
<cc:implementation>

    <p:dialog  header="#{cc.attrs.header}"
        id="#{cc.attrs.id}" >


    </p:dialog>


</cc:implementation>

and I would like to insert another components inside myDialog, but it doesn't work.

example.xhtml

<puc:myDialog  header="Hi" id="myDialogId">
        **This code doesn't appear. Why?**  
        <p:dataGrid>
            <p:row>
                <p:column>
                <p:inputText></p:inputText>
                </p:column>
                </p:row>
        </p:dataGrid>

</puc:myDialog>
1
Where exactly did you read about using the id="#{cc.attrs.id}" nonsense? This is not the first time I see a JSF starter using this for an unclear reason. So there must be somewhere a poor quality resource spreading this misinformation. Can you please point out which one it is so that I can contact its author? - BalusC

1 Answers

2
votes

You are missing the cc:insertChildren tag.

<cc:implementation>
 <p:dialog  header="#{cc.attrs.header}" id="#{cc.attrs.id}" >
  <cc:insertChildren />
 </p:dialog>
</cc:implementation>

Any child components or template text within the composite component tag in the using page will be reparented into the composite component at the point indicated by this tag’s placement within the composite:implementation section.