1

I am new to JSF, so I have many problems with it. I have solved much, but now I have a problem when I make composite component of column.

This is the code:

myPage.xhtml:

<h:dataTable  > 
    <util:myCol />
</h:dataTable>

myCol.xhtml:

<composite:interface>
</composite:interface> 
<composite:implementation>
    <h:column>
        <f:facet name="header" >
           <h:outputText value="user name" />
        </f:facet>
        <h:outputText value="some data" />
    </h:column>
</composite:implementation>

The problem is that the column does not render.

So I have changed a little in code:

myPage.xhtml:

<h:dataTable  > 
    <h:column>
        <util:myCol />
    </h:column>
</h:dataTable>

myCol.xhtml:

<composite:interface>
</composite:interface> 
<composite:implementation>
    <f:facet name="header" >
        <h:outputText value="user name" />
    </f:facet>
    <h:outputText value="some data" />
</composite:implementation>

Here the column renders, but the header "user name" does not appear.

How to solve the problem? Thanks in advance.

afi
  • 11
  • 1
  • 3
  • My solution, see: http://stackoverflow.com/questions/7891650/using-compositeinsertfacet-renderfacet-does-not-work-inside-tdatatable/9091313#9091313 – Lenik Feb 01 '12 at 05:50

4 Answers4

1

Case 1:

dataTable only treats column control children as columns. You are adding a composite control to the dataTable and a the column to the composite control.

Case 2:

The problem is probably to do with where the facets are set. These are set on a map on the parent control. The control you are adding the header facet to is the composite control, not the column.

Note: the links are to JSF 1.2 (JEE5) stuff, but the principle still applies.

McDowell
  • 107,573
  • 31
  • 204
  • 267
  • thank you very much but I can not understand what must do to make my application work by use cloumn composite component with facet ... – afi Jan 31 '10 at 11:58
  • You will probably have to use the ` – McDowell Jan 31 '10 at 15:23
  • what you meaning in "Since there is no such component, you'll have to write one" ...I read specification and I found UIColumn . please give me clear example about make composite Column .. thank you and I am so sorry for my questions – afi Feb 01 '10 at 11:51
  • I mean that there is no class that is a _UIColumn_ AND implements _NamingContainer_ AND is defined in a _faces-config.xml_. That is, `public class MyColumn extends UIColumn implements NamingContainer { ...` http://java.sun.com/javaee/5/docs/tutorial/doc/bnavg.html _(You shouldn't need to define any tags in this case - just the Java class and the config descriptor.)_ – McDowell Feb 01 '10 at 12:50
1

I don't know if you still follow this thread, but we had problems inserting facets due to a bug. Starting the content inside the facet with a comment (server side comment < ! - - - - > ) may solve the problem showing the content. We encountered problems with facets having one liners in there.. putting an extra comment as the first statement is the workaround for the problem.

Kind regards, Gijs

0

Does it render correctly when you have all of the JSF on one page? Setting up your JSF on a single page at first can be helpful to make sure that the basics are right; after that works, you can break it up into composite components.

Also, I have noticed (using JSF and Richfaces) that sometimes you can't separate 'parents' and 'children' at times; a rich:toolBar and it's rich:toolBarGroup's need to be on the same actual page, for example. I haven't worked with Facelets much so you might have a different situation.

Best of luck.

Edit:

Try pulling the header out of the composite control, i.e.:

<h:dataTable  > 
    <h:column>
        *HEADER_FACET_GOES_HERE*
        <util:myCol />
    </h:column>
</h:dataTable>
Jon Onstott
  • 13,499
  • 16
  • 80
  • 133
0

Use composite:facet in interface and composite:renderFacet or composite:insertFacet in implementation.

<composite:interface>
    <composite:facet name="foo"/>
    <composite:attribute name="value"/>
</composite:interface>
<composite:implementation>
    <h:inputText id="value" value="#{cc.attrs.value}"/>
    <composite:renderFacet name="foo"/>
    <composite:insertChildren/>
</composite:implementation>

lexicore
  • 42,748
  • 17
  • 132
  • 221